Skip to content

Commit a731309

Browse files
author
Robert
committed
Remove version ID from SSE events
1 parent 17a4b9a commit a731309

3 files changed

Lines changed: 6 additions & 14 deletions

File tree

docs/src/usage/change-notifications.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ When `AddVersion` accepts a new version for that client, the stream emits a
1111

1212
```text
1313
event: version
14-
data: {"clientId":"...","versionId":"..."}
14+
data: {"clientId":"..."}
1515
```
1616

1717
This endpoint is only an invalidation signal. Clients should perform a normal

server/src/api/add_version.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub(crate) async fn service(
7474
rb.append_header((SNAPSHOT_REQUEST_HEADER, "urgency=high"));
7575
}
7676
};
77-
server_state.changes.notify(client_id, version_id);
77+
server_state.changes.notify(client_id);
7878
Ok(rb.finish())
7979
}
8080
Ok((AddVersionResult::ExpectedParentVersion(parent_version_id), _)) => {
@@ -148,11 +148,9 @@ mod test {
148148
// the passed parent version ID, at least
149149
let new_version_id = resp.headers().get("X-Version-Id").unwrap();
150150
assert!(new_version_id != &version_id.to_string());
151-
let new_version_id = Uuid::parse_str(new_version_id.to_str().unwrap()).unwrap();
152151

153152
let event = changes.next().await.unwrap();
154153
assert_eq!(event.client_id, client_id);
155-
assert_eq!(event.version_id, new_version_id);
156154

157155
// Shapshot should be requested, since there is no existing snapshot
158156
let snapshot_request = resp.headers().get("X-Snapshot-Request").unwrap();

server/src/api/events.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ use std::{
99
collections::HashMap,
1010
sync::{Arc, Mutex},
1111
};
12-
use taskchampion_sync_server_core::{ClientId, VersionId};
12+
use taskchampion_sync_server_core::ClientId;
1313

1414
#[derive(Clone, Debug, Serialize)]
1515
#[serde(rename_all = "camelCase")]
1616
pub(crate) struct ChangeEvent {
1717
pub(crate) client_id: ClientId,
18-
pub(crate) version_id: VersionId,
1918
}
2019

2120
#[derive(Clone, Default)]
@@ -35,11 +34,8 @@ impl ChangeNotifier {
3534
rx
3635
}
3736

38-
pub(crate) fn notify(&self, client_id: ClientId, version_id: VersionId) {
39-
let event = ChangeEvent {
40-
client_id,
41-
version_id,
42-
};
37+
pub(crate) fn notify(&self, client_id: ClientId) {
38+
let event = ChangeEvent { client_id };
4339
let mut subscribers = self
4440
.subscribers
4541
.lock()
@@ -90,13 +86,11 @@ mod test {
9086
async fn notifier_delivers_events_for_matching_client() {
9187
let notifier = ChangeNotifier::default();
9288
let client_id = Uuid::new_v4();
93-
let version_id = Uuid::new_v4();
9489
let mut rx = notifier.subscribe(client_id);
9590

96-
notifier.notify(client_id, version_id);
91+
notifier.notify(client_id);
9792
let event = rx.next().await.unwrap();
9893
assert_eq!(event.client_id, client_id);
99-
assert_eq!(event.version_id, version_id);
10094
}
10195

10296
#[actix_rt::test]

0 commit comments

Comments
 (0)