After the announcement of distributed actors, I was excited and began to dive deeper into the topic. Unfortunately, couldn't find any examples that covered it comprehensively. However, this hasn't stopped me from learning. I started reading books about Akka and Erlang and created a small repository where porting Akka in action examples, but quickly realised that there were still some missing pieces.
So, to fill those gaps, I've created a small example with several goals:
To reduce the learning curve for new developers.
To cover, at least partially, some concepts like event sourcing.
While it's based on Swift distributed actors, the project also incorporates:
As a learning project, it could also serve as a helpful example for other developers.
Currently, the app is in an early stage, though basic functionalities are working:
You can spin several nodes and form a cluster, such as:
main, which orchestrates other actors and connections.
room, to spawn room actors.
database, for persistency and event sourcing. You can even play around and split it into two separate nodes.
Basic fault tolerance, in case of room and database unavailability (time out, crash)âthe main node can continue working and spawn all needed actors on its own.
A basic iOS/macOS app client with chat, user/room creation, and room search.
Would be nice to hear some feedback. Want to be this example as actor modelcorrect as possible, and as I'm only learning and don't have much of experience in writing concurrent and distributed apps using actor modelâwould be nice to hear some thoughts from people who have this experience.
Also would like to mention next steps I want to cover:
Debugging is hard. Like really hard sometimes, even on a single node (cluster can just crash ). Wanna add swift distributed tracing
@Honza_Dvorsky pointed out that it would be nice to add swift openapi generator, which is a good point. Will try!
Maybe adding some simple authentication an spin application somewhere on my raspberry pi4 or VPS and have some more insights
Yes, event-sourcing would be a nice standalone package! There's various approaches but the overall idea should be quite abstractible, especially with macros and the flexibility you get from actorReady so you can store it and register it for "when events arrive we'll call you"
I'm personally a huge fan of doing something like LiveView, that'd be really cool
Seen some interest in the community before, and maybe interesting for someone, decided to pack some stuff into Virtual Actor pattern, so here is some basic and naive implementation:
Idea is that you can have transparent actors in the system referenced by some custom id, e.g.
let actor = try await factory.get(id: "first_example", dependency: SomeDependency())