actor4k: A small actor system written in kotlin us...
# random
y
actor4k: A small actor system written in kotlin using Coroutines. What is actor model: The actor model is a design paradigm for building concurrent systems where the basic unit of computation, known as an actor, encapsulates its own state and behavior and interacts with others solely through asynchronous message passing. Each actor processes messages sequentially, which simplifies managing state changes and avoids common pitfalls like race conditions and deadlocks that arise with traditional multithreading approaches. This model is particularly useful for highly concurrent, distributed, and fault-tolerant systems. Its scalability and resilience come from the ability to isolate errors within individual actors through supervision strategies, making it a fitting choice for applications such as real-time data processing, microservices architectures, and any system that requires robust fault isolation and maintainability. https://github.com/smyrgeorge/actor4k
p
Could it be possible to pass a custom Actor factory to the Actor system? In a way I could make the actors dependency injectable? Similar to how ViewModel does in Android. Because one problem I see, judging by the readme example, is how to do dependency injection on an Actor.
y
Sure take a look here:
Copy code
// Create the Actor Registry.
val registry = SimpleActorRegistry()
    .register(AccountActor::class) { key -> AccountActor(key) }

// Start the actor system.
ActorSystem
    .register(SimpleLoggerFactory())
    .register(SimpleStats())
    .register(registry)
    .start()
You can tell to the actor registry how each actor is created.
@Pablichjenkov for any other questions or ideas you can also open a thread here: https://github.com/smyrgeorge/actor4k/discussions
👍 1
p
Ohh, the register() function provides the factory for the Actor subclass one provides. I missed that. It seems also I can be able to provide my own implementation of an Actor registry. Ok thanks
y
Sure, you can pass your own implementation 😄
I’ll make the documentation a bit clearer
👍 1