Skip to content

Commit 886846a

Browse files
Add some design diagrams (#7)
* Add some design diagrams * bump CI workflow * bump CI
1 parent 0680419 commit 886846a

File tree

2 files changed

+109
-1
lines changed

2 files changed

+109
-1
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
################################################################################
1313

1414
[workspace]
15-
exclude = [".vscode/*", ".github/*", "tools/*", ".gitignore"]
15+
exclude = [".vscode/*", ".github/*", "tools/*", ".gitignore", ".devcontainer/*"]
1616
members = ["up-subscription", "up-subscription-cli"]
1717
resolver = "2"
1818

README.md

+108
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ This codebase is heavily work in progress - among the next things to do and inve
2121
- Is it expected that a uEntity can register more than one custom topic receiving update notifications?
2222
- Is it supposed to be possible to register remote uuris as notification topics?
2323
- Should remote UUris be excluded from all listeners except `subscribe` and `unsubscribe`?
24+
- Do we need update/change notifications when remote SubscriptionResponses come in?
2425

2526
## Getting Started
2627

@@ -71,3 +72,110 @@ To run (and auto-build if required) the container, in the project root run
7172
```console
7273
docker-compose up
7374
```
75+
76+
## Design
77+
78+
USubscription service implementation is a three-tiered design, with the following layers:
79+
80+
- UTransport listeners, which link USubscription service methods to a specific transport implementation
81+
- USubscription service, which is called from the listeners and performs input validation as well as high-level business logic orchestration; it acts as a frontend for
82+
- subscription and notification manager actors, which contain the book-keeping and core business logic around subscriptions and notifications
83+
84+
The overall usubscription service implementation comprises the following building blocks:
85+
86+
```mermaid
87+
block-beta
88+
columns 3
89+
90+
transport(("UTransport")):3
91+
space:3
92+
93+
block:listeners:3
94+
SubscribeListener
95+
UnsubscribeListener
96+
etcListener
97+
end
98+
space:3
99+
100+
usubscription:3
101+
space:3
102+
103+
subscription_manager:1
104+
space:1
105+
notification_manager:1
106+
space:3
107+
108+
task("remote_(un)subscribe")
109+
space:2
110+
111+
transport--"rpc call"-->listeners
112+
listeners-->usubscription
113+
usubscription--"mpsc channel"-->subscription_manager
114+
usubscription--"mpsc channel"-->notification_manager
115+
subscription_manager--"spawn"-->task
116+
117+
classDef smaller font-size:small;
118+
class SubscribeListener,UnsubscribeListener,etcListener smaller
119+
class task smaller
120+
```
121+
122+
$~$
123+
124+
A basic interaction flow for a client requesting a subscription is illustrated below:
125+
126+
```mermaid
127+
sequenceDiagram
128+
actor UTransport
129+
box WhiteSmoke USUbscription Service
130+
participant subscribe listener
131+
participant usubscription
132+
participant subscription_manager
133+
participant notification_manager
134+
end
135+
136+
UTransport-->>+subscribe listener: SubscriptionRequest
137+
subscribe listener->>usubscription: subscribe()
138+
139+
activate usubscription
140+
usubscription->>subscription_manager: send(SubscriptionEvent::AddSubscription)
141+
activate subscription_manager
142+
subscription_manager-->>subscription_manager: validate and store subscription info
143+
144+
alt is local topic
145+
subscription_manager-->>usubscription: send(SubscriptionStatus::SUBSCRIBED)
146+
147+
else is remote topic
148+
subscription_manager-->>usubscription: send(SubscriptionStatus::SUBSCRIBE_PENDING)
149+
150+
create participant remote_subscribe
151+
subscription_manager-->>remote_subscribe: spawn()
152+
deactivate subscription_manager
153+
remote_subscribe-->>UTransport: send remote SubscriptionRequest
154+
UTransport-->>remote_subscribe: remote SubscriptionResponse
155+
156+
# remote_subscribe->>+notification_manager: send(NotificationEvent::StateChange)
157+
# notification_manager-->>UTransport: send(Update) to default notification channel
158+
# loop Every custom notification
159+
# notification_manager-->>UTransport: send(Update) custom channel
160+
# end
161+
# notification_manager-->>-remote_subscribe: send(())
162+
163+
activate subscription_manager
164+
destroy remote_subscribe
165+
remote_subscribe-->>subscription_manager: send(RemoteSubscriptionEvent::RemoteTopicStateUpdate)
166+
subscription_manager-->>subscription_manager: update subscription info
167+
end
168+
deactivate subscription_manager
169+
170+
usubscription->>subscribe listener: SubscriptionResponse
171+
subscribe listener-->>UTransport: SubscriptionResponse
172+
173+
usubscription->>+notification_manager: send(NotificationEvent::StateChange)
174+
notification_manager-->>UTransport: send(Update) to default notification channel
175+
loop Every custom notification
176+
notification_manager-->>UTransport: send(Update) custom channel
177+
end
178+
notification_manager-->>-usubscription: send(())
179+
deactivate usubscription
180+
181+
```

0 commit comments

Comments
 (0)