Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PoC: DistributedSequence that is DistributedActorSystem agnostic! #1171

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ktoso
Copy link
Member

@ktoso ktoso commented Oct 25, 2024

This is a simple, yet proving the point, implementation of a DistributedSequence<Element, ActorSystem>!

Thanks to advances in most recent Swift we're able to express such generic over actor system protocols and provide general utility libraries which work with any distributed actor system.

Implementation details are simple in this one, we'd need to be a bit smarter with potentially batching (high-low watermark fetching) as well as timeouts and failure handling of the subscriber (when the subscriber node dies). But this in general proves the mechanisms that one would use to implement such type.

Since it is ClusterSystem agnostic, we could make this a general type in Distributed module!

@ktoso
Copy link
Member Author

ktoso commented Oct 25, 2024

@swift-server-bot test this please

@ktoso
Copy link
Member Author

ktoso commented Oct 25, 2024

TODO, maybe make it single subscriber

TODO, if it's possible to do a proxy with child tasks, like these in some other libs

func stream(body: (some AsyncWriter<Int>, some AsyncSequence<Int>) async -> Void) async {
  await withTaskGroup { group in
    let writer = ...
    let sequence = ...
    group.addTask {
      // Pull data from writer and push data to sequence
    }
   await body(writer, sequence)
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant