Conversation
Collaborator
Author
|
Question do we like having |
Collaborator
Author
|
@RemiSoummer @ivalaginja Your opinion on this new Service attribute type? |
Collaborator
Author
|
I just added documentation as well. This includes a lot of documentation on how to write your own service, adapted and extended from @alexisyslau initial text. |
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
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.
Summary
This PR introduces Slots, a unified communication primitive that replaces the separate DataStreams and Properties APIs. Slots provide typed, bidirectional communication channels between services with built-in error handling, cancellation support, and confirmation mechanisms.
What are Slots?
Slots are named, typed communication channels that connect services. Unlike the previous API which had separate concepts for:
Slots unify these into a single concept:
The main difference with properties is that other people can subscribe to updates to that property and can retrieve the property value on demand without requiring the service to tell them what it is. The main difference with data streams is that slots allow for confirmation of sets. Additionally, data streams unidirectional (either service->outside or outside->service) without indicating which; slots are either uni- or bi-directional and has specific access patterns for each direction of communication.
Key Features
1. Type Safety
Slots are typed at creation time with three supported types:
Json- None, Integer, Float, Dictionaries, Lists or any combination of thoseRaw- Binary bytesArray- NumPy arrays2. Synchronous with Confirmation
The
set()method blocks until the service confirms the operation succeeded (or fails). This makes configuration changes reliable.3. Asynchronous Option
The
set_async()method returns immediately with a trace ID for tracking. Useful for high-frequency updates where you don't need immediate confirmation.4. Cancellation
Long-running setter operations can be cancelled via a dedicated topic. The service can check
context.is_cancelled()and abort gracefully. Currently, there is no way to call this functionality but I want to have the backend functionality in place for this.5. Error Handling
Clear exceptions tell you exactly what went wrong:
SlotTimeoutError- Service didn't respond in timeSlotSetterError- Service's setter callback threw an exceptionSlotCancelledError- Operation was cancelledUsage Examples
Service Side (Python)
Proxy Side (Python)
API Reference
Service Methods
Slot Methods (Service Side)
SlotProxy Methods (Proxy Side)
SlotContext (Available in Setter Callbacks)
Design Decisions
set()method blocks until confirmation. This is what most users expect for configuration operations. Useset_async()when you need fire-and-forget.get()andset()- the type handling is automatic based on the slot's configured type.Migration from Old API
Before (Properties):
After (Slots):
Before (DataStreams):
After (Slots):
Testing
Comprehensive tests have been added in
tests/test_service.py:Future Work
Things to consider for the future: