Migrating Cluster system to Swift structured concurrency

Last and this year I had some progress in developing examples (e.g. swift-chat) or brief prototypes [1] of extension plugins on cluster system, like event sourcing and virtual actors. Also with the help of community we're slowly fixing issues in cluster system itself.

While Cluster system is stable and working, it was written before Swift's structured concurrency was introduced and actually uses its own concurrency runtime. This is kinda blocker for me right now, as to develop things further I want system to be stable and up to date with current state of the art. With @ktoso we agreed that best solution right now would be to rewrite system from scratch, here is a issue ticket explaining the motivation and steps: Migrate Cluster system to Swift structured concurrency Ā· Issue #1215 Ā· apple/swift-distributed-actors Ā· GitHub.

I've finally started to reimplement cluster system slowly, and while doing this—realised that steps on how to implement your own cluster system from scratch could be interesting for people who wants to work with distributed actors. Swift is unique in a way that one of the main parts of distributed actors is bring your own cluster runtime. While Cluster system aims for server side environment, backed by swift-nio, there are many other potential use cases.

While I'm not sure I can fully document it[2], I've decided to create a separate topic here where will try to note what was done and explain each steps as a guide—so that one can read and understand those steps and complexity. Guess, in any case, these notes will be beneficial for later documentation.

So, let's try to dive in and explore this together!


A quick note: I’m learning a lot myself while working on this project, so please don’t hesitate to ask questions, point out issues, or suggest improvements. Any discussion around this topic really helps motivate me to keep developing and writing more about it.:slightly_smiling_face:


  1. Though fully working! As mentioned later I just need to focus on migrating topic before finishing plugins. ā†©ļøŽ

  2. At least now, as I don't have a lot of time. Maybe after migrating will create a separate project for that. ā†©ļøŽ

19 Likes

We’ve been chatting for a while, so I’m very supportive of the effort.

Maintanance of the cluster has fallen behind as you noted… but it would be very viable to ā€œreviveā€ it through a fresh start like this. I’m supportive of this effort and happy to remain involved merge PRs and offer advice etc.

I should also perhaps address the general status of distributed actors – they’re (the language feature) doing very well, and I’m supporting a bunch of adopters that I can’t share too much information about though. The cluster was very much a proof of what we can build using the language feature, and sadly has not received much adoption, unlike the language feature itself. Either way, the feature is doing well and we’re planning improvements to it.

Thank you for picking up the cluster work while I’m busy more on the language side of things,

Thanks and godspeed!

8 Likes

Thx!

Yeah, I also emphasized in the post that everything is actually working — especially the language features. It’s just the Cluster system that needs to be updated to move forward.

There’s some interest in helping with the migration, so I’ll try to organize that (anyone welcome, so just ping me in dm!). In the meantime, I’ll start posting some thoughts here about distributed actors and the steps I’ve already taken.

3 Likes