-
Notifications
You must be signed in to change notification settings - Fork 12
Move InMemorySubscriber from L2 to L3 client module #56
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
neelam-kushwah
merged 10 commits into
eclipse-uprotocol:main
from
neelam-kushwah:subscription_service
Jul 24, 2024
Merged
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9ceedfa
Move InMemorySubscriber from L2 to L3 client module
neelam-kushwah 8710a7b
Updated UListener on_receive method to be asynchronous and add additi…
neelam-kushwah 929f0d8
Update READMEs
neelam-kushwah bd2645d
Bump version to 0.2.0 for major release introducing L2 and L3.
neelam-kushwah bf583e0
Delete client README.html
neelam-kushwah a9a1b94
Incorporated Reviewers comment
neelam-kushwah 824e861
Fixed review comments
neelam-kushwah c29da91
Fixed communication status issue
neelam-kushwah b4dac12
Added subscriber info in unsubscribe request
neelam-kushwah e259164
Address review comments
neelam-kushwah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Empty file.
Empty file.
Empty file.
349 changes: 314 additions & 35 deletions
349
..._communication/test_inmemorysubscriber.py → ...est_v3/test_inmemoryusubcriptionclient.py
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # Application Layer APIs (uP-L3 Interface) | ||
|
|
||
| The following module includes the client-facing https://github.com/eclipse-uprotocol/up-spec/tree/main/up-l3[Application Layer (uP-L3)] interfaces to communication with USubscription, UDiscovery, and UTwin services. | ||
|
|
||
|
|
||
| ## uP-L3 Interfaces | ||
|
|
||
| .Interfaces (uP-L3 Interface) | ||
| [cols="1,1,3",options="header"] | ||
| |=== | ||
| | Interface | Implementation(s) | Description | ||
|
|
||
| | xref:/v3/usubscriptionclient.py[*USubscriptionClient*] | xref:/v3/InMemoryUSubscriptionClient.py[InMemoryUSubscriptionClient] | Subscription Management APIs to subscribe(), unsubscribe() and fetch information from the subscription database. | ||
| |=== | ||
|
|
||
|
|
||
| The module includes the interface for the client-facing APIs as well as a simple in-memory implementation that is based on the uP-L2 in-memory implementations. the term in-memory is used to indicate that the data required by the code is cached inside of the object and not persisted to a given database backend, this design is useful for embedded applications (i.e. in the vehicle) however will not scale to the multi-tenanted cloud applications. | ||
|
|
||
| ## Examples | ||
|
|
||
|
|
||
| === Subscribe and Unsubscribe | ||
| [,python] | ||
| ---- | ||
| transport = # your UTransport instance | ||
|
|
||
| #subscription topic | ||
| topic : UUri = UUri( ue_id=4, ue_version_major=1, resource_id=0x8000) | ||
|
|
||
| #Listener to process incoming events on the topic | ||
| class MySubscriptionListener(UListener): | ||
| def on_receive(self, umsg: UMessage) -> None: | ||
| # Handle receiving published message | ||
| pass | ||
|
|
||
| listener = MySubscriptionListener() | ||
|
|
||
| # Optional handler that is called whenever the SubscriptionState changes for the subscriber | ||
| class MySubscriptionChangeHandler(SubscriptionChangeHandler) | ||
| def handle_subscription_change(self, topic: UUri, status: SubscriptionStatus) -> None: | ||
| # Handle subscription status changes if you're interested like when | ||
| # the subscription state changes from SUBSCRIBE_PENDING to SUBSCRIBED | ||
| pass | ||
|
|
||
| subscriber : InMemoryUSubscriptionClient = InMemoryUSubscriptionClient(transport) | ||
| response : SubscriptionResponse = subscriber.subscribe(topic, listener, CallOptions.DEFAULT, MySubscriptionChangeHandler()) | ||
|
|
||
| #UnSubscribe from the topic | ||
| status : UStatus = subscriber.unsubscribe(topic, listener) | ||
| ---- |
Empty file.
Empty file.
Empty file.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.