-
Notifications
You must be signed in to change notification settings - Fork 0
Distributed Collections #43
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Added tests.
…iteration on multiple threads. Started client work.
Added Clear to Fizzing operations.
Client connects to server collection now.
Continued work on messaging.
… Task.Run, but with a state passed. Initial channel broadcast working. Items are being sent out of order after buffer has been filled on the server.
Started work on Generator.
Processed all diagnostics instead of until one failed.
…s during growing/modifications.
Changed errors to display on the interface if it is in the same assembly or the nexus implementation if not.
Started extracting common logic into NexusCollection class.
Further extraction of common logic.
Added tests.
Added documentation.
Determine why pipe.CompleteTask.ContinueWith is firing first.
… captured context. Added tests.
…stening. Fixed tests.
Added SnapshotTests. Added CircularListTests.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a foundational abstraction for remotely synchronized collections and a concrete list interface that builds on it. At its core, INexusCollection captures the lifecycle of a server-backed collection: Once connected, clients can subscribe to the Changed event (an ISubscriptionEvent) to receive notifications whenever the server-side data mutates, and unsubscribe by disposing the returned token.
INexusList inherits from INexusCollection and IEnumerable, offering a list-like API but with each mutation routed to the server. Methods like AddAsync, InsertAsync, RemoveAsync, RemoveAtAsync, ClearAsync, MoveAsync, and ReplaceAsync all return Task, where true indicates the server accepted and applied the operation and false signals an invalid index, non-existent item, or a no-op. This pattern allows client code to react appropriately—retry, log, or ignore—depending on whether the remote operation succeeded. Read-only operations remain synchronous: you can call Contains, IndexOf, retrieve Count, check IsReadOnly (which is always false in server-to-client mode), use the indexer this[int index], or copy contents into a provided array via CopyTo, with the usual argument validation exceptions. All data accessed in the synchronous methods access the current state on the client and may not reflect the latest state on the server if accessed between the server broadcast update and the client side read.
The Changed subscription event abstraction is factored into ISubscriptionEvent offering a Subscribe method that accepts a handler and returns an IDisposable for unsubscription.
Under the hood, this architecture extracts connection handling and event subscription so that other collection types (e.g., sets or maps) can plug into the same infrastructure and implement their own mutation operations according to their specific semantics.
Details
New Public API
The *Async methods all execute the changes on the server and wait for the server confirmation of the change operation. If the Task returns false, the value was not updated on the server. This may indicate that the list was cleared or the operation was rendered a noop.
Synchronized List Usage
The list must be decorated with the NexusCollectionAttribute, otherwise the Server nexus it will throw. Synchronized collections are only allowed on the server nexus. Collections are to be configured as either
BiDrirectional
orServerToClient
.IAsyncEnumerable Usage
The preferred method of reading channels is now using the IAsyncEnumerable on the provided INexusChannelReader. This allows for the most efficient buffering of data while reading and simplifies channel closure whether graceful or not.
Breaking Changes
Misc