Skip to content

Commit 698bf5b

Browse files
committed
Use const for notification resource ID
1 parent 2b32584 commit 698bf5b

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

up-subscription/src/notification_manager.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ use crate::{
3030
USubscriptionConfiguration,
3131
};
3232

33+
// From usubscription.proto, the uprotocol.notification_topic resource ID
34+
pub(crate) const SOURCE_URI_RESOURCE_ID: u16 = 0x8000;
35+
3336
// This is the core business logic for tracking and sending subscription update notifications. It is currently implemented as a single
3437
// event-consuming function `notification_engine()`, which is supposed to be spawned into a task, and process the various notification
3538
// `Events` that it can receive via tokio mpsc channel.
@@ -213,7 +216,7 @@ pub(crate) async fn notification_engine(
213216
);
214217

215218
match UMessageBuilder::notification(
216-
configuration.get_resource_uri(0x8000),
219+
configuration.get_resource_uri(SOURCE_URI_RESOURCE_ID),
217220
subscribers_entry.clone(),
218221
)
219222
.build_with_protobuf_payload(&update)

up-subscription/src/tests/notification_manager_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ mod tests {
3030
use crate::{
3131
configuration::DEFAULT_COMMAND_BUFFER_SIZE,
3232
helpers,
33-
notification_manager::{notification_engine, NotificationEvent},
33+
notification_manager::{notification_engine, NotificationEvent, SOURCE_URI_RESOURCE_ID},
3434
test_lib,
3535
usubscription::{SubscriberUUri, TopicUUri},
3636
USubscriptionConfiguration,
@@ -279,7 +279,7 @@ mod tests {
279279
// this is the expected direct notification message
280280
let config = Arc::new(CommandSender::get_config());
281281
let expected_notitication_message = UMessageBuilder::notification(
282-
config.get_resource_uri(0x8000),
282+
config.get_resource_uri(SOURCE_URI_RESOURCE_ID),
283283
interested_subscriber_uri.clone(),
284284
)
285285
.with_message_id(UUID::build())

0 commit comments

Comments
 (0)