Skip to content

Commit 3f9dcf6

Browse files
Implement dsn~usubscription-change-notification-update (eclipse-uprotocol#21)
* Implement dsn~usubscription-change-notification-update * minor improvements to devcontainer config * deal with new clippy rules
1 parent 8a70a87 commit 3f9dcf6

File tree

14 files changed

+231
-88
lines changed

14 files changed

+231
-88
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ ARG TARGETARCH
1717

1818
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
1919
&& apt-get -y install \
20+
cmake \
2021
curl \
2122
gcc \
2223
git \

.env.oft-current

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ UP_SPEC_FILE_PATTERNS="up-spec/up-l3/usubscription/v3/README.adoc"
1717

1818
# The file patterns that specify this component's resources which contain specification items
1919
# that cover the requirements
20-
COMPONENT_FILE_PATTERNS="*.adoc *.md *.rs .github up-subscription/src"
20+
COMPONENT_FILE_PATTERNS="*.md .github up-subscription/src"
2121

2222
OFT_FILE_PATTERNS="$UP_SPEC_FILE_PATTERNS $COMPONENT_FILE_PATTERNS"
2323
OFT_TAGS=""

.env.oft-latest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ UP_SPEC_FILE_PATTERNS="up-spec/up-l3/usubscription/v3/README.adoc"
1717

1818
# The file patterns that specify this component's resources which contain specification items
1919
# that cover the requirements
20-
COMPONENT_FILE_PATTERNS="*.adoc *.md *.rs .github up-subscription/src"
20+
COMPONENT_FILE_PATTERNS="*.md .github up-subscription/src"
2121

2222
OFT_FILE_PATTERNS="$UP_SPEC_FILE_PATTERNS $COMPONENT_FILE_PATTERNS"
2323
OFT_TAGS="_,uSubscription"

tools/coverage.sh

100644100755
File mode changed.

tools/generate_test_coverage_report.sh

100644100755
File mode changed.

tools/startup.sh

100644100755
File mode changed.

up-subscription-cli/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl StartupError {
5858
impl std::fmt::Display for StartupError {
5959
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6060
match self {
61-
Self::ConfigurationError(e) => f.write_fmt(format_args!("Configuration error: {}", e)),
61+
Self::ConfigurationError(e) => f.write_fmt(format_args!("Configuration error: {e}")),
6262
}
6363
}
6464
}
@@ -193,7 +193,7 @@ async fn main() {
193193
Ok(_) => {
194194
debug!("Success, running daemonized");
195195
}
196-
Err(e) => error!("Error, {}", e),
196+
Err(e) => error!("Error, {e}"),
197197
}
198198
}
199199

up-subscription/src/common/helpers.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ where
3636
{
3737
task::spawn(async move {
3838
if let Err(e) = fut.await {
39-
error!("{}", e)
39+
error!("{e}")
4040
}
4141
})
4242
}
@@ -53,8 +53,7 @@ where
5353
{
5454
if resource_id != expected_resource_id {
5555
return Err(ServiceInvocationError::InvalidArgument(format!(
56-
"Wrong resource ID (expected {}, got {})",
57-
expected_resource_id, resource_id
56+
"Wrong resource ID (expected {expected_resource_id}, got {resource_id})"
5857
)));
5958
}
6059
let Some(payload) = payload else {

up-subscription/src/configuration.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,10 @@ impl USubscriptionConfiguration {
8686
let persistency_path = if let Some(path_string) = persistency_path {
8787
let p = Path::new(&path_string);
8888
p.try_exists().unwrap_or_else(|_| {
89-
panic!("Persistency storage path does not exist {}", path_string)
89+
panic!("Persistency storage path does not exist {path_string}")
9090
});
9191
if !p.is_dir() {
92-
panic!(
93-
"Persistency storage path is not a directory {}",
94-
path_string
95-
);
92+
panic!("Persistency storage path is not a directory {path_string}");
9693
}
9794
p.to_path_buf()
9895
} else {

up-subscription/src/notification_manager.rs

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,43 @@ pub(crate) enum NotificationEvent {
6464
},
6565
}
6666

67+
impl PartialEq for NotificationEvent {
68+
fn eq(&self, other: &Self) -> bool {
69+
match (self, other) {
70+
(
71+
NotificationEvent::StateChange {
72+
subscriber: s1,
73+
topic: t1,
74+
status: st1,
75+
..
76+
},
77+
NotificationEvent::StateChange {
78+
subscriber: s2,
79+
topic: t2,
80+
status: st2,
81+
..
82+
},
83+
) => s1 == s2 && t1 == t2 && st1 == st2,
84+
(
85+
NotificationEvent::AddNotifyee {
86+
subscriber: s1,
87+
topic: t1,
88+
},
89+
NotificationEvent::AddNotifyee {
90+
subscriber: s2,
91+
topic: t2,
92+
},
93+
) => s1 == s2 && t1 == t2,
94+
(
95+
NotificationEvent::RemoveNotifyee { subscriber: s1 },
96+
NotificationEvent::RemoveNotifyee { subscriber: s2 },
97+
) => s1 == s2,
98+
// Don't care about the test-only variants
99+
_ => false,
100+
}
101+
}
102+
}
103+
67104
// Keeps track of and sends subscription update notification to all registered update-notification channels.
68105
// Interfacing with this purely works via channels.
69106
pub(crate) async fn notification_engine(
@@ -186,7 +223,7 @@ pub(crate) async fn notification_engine(
186223
}
187224
}
188225

189-
let _r = respond_to.send(());
226+
let _ = respond_to.send(());
190227
}
191228
#[cfg(test)]
192229
NotificationEvent::GetNotificationTopics { respond_to } => {

0 commit comments

Comments
 (0)