Skip to content

Commit

Permalink
Pull in recent changes in usubscription spec objects
Browse files Browse the repository at this point in the history
  • Loading branch information
AnotherDaniel authored and sophokles73 committed Nov 12, 2024
1 parent 1a14313 commit a867e52
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions src/communication/default_pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use tracing::{debug, info};

use crate::{
core::usubscription::{
self, State, SubscriberInfo, SubscriptionRequest, USubscription, UnsubscribeRequest, Update,
self, State, SubscriptionRequest, USubscription, UnsubscribeRequest, Update,
},
LocalUriProvider, UListener, UMessage, UMessageBuilder, UStatus, UTransport, UUri,
};
Expand Down Expand Up @@ -245,7 +245,7 @@ impl Publisher for SimplePublisher {
/// handler is being looked up and invoked.
pub struct InMemorySubscriber {
transport: Arc<dyn UTransport>,
uri_provider: Arc<dyn LocalUriProvider>,
_uri_provider: Arc<dyn LocalUriProvider>,
usubscription: Arc<dyn USubscription>,
notifier: Arc<dyn Notifier>,
subscription_change_listener: Arc<SubscriptionChangeListener>,
Expand Down Expand Up @@ -305,7 +305,7 @@ impl InMemorySubscriber {
.await?;
Ok(InMemorySubscriber {
transport,
uri_provider,
_uri_provider: uri_provider,
usubscription,
notifier,
subscription_change_listener,
Expand All @@ -329,20 +329,12 @@ impl InMemorySubscriber {
.and_then(|_ok| self.subscription_change_listener.clear())
}

fn subscriber_info(&self) -> SubscriberInfo {
SubscriberInfo {
uri: Some(self.uri_provider.get_source_uri()).into(),
..Default::default()
}
}

async fn invoke_subscribe(
&self,
topic: &UUri,
subscription_change_handler: Option<Arc<dyn SubscriptionChangeHandler>>,
) -> Result<State, RegistrationError> {
let subscription_request = SubscriptionRequest {
subscriber: Some(self.subscriber_info()).into(),
topic: Some(topic.to_owned()).into(),
..Default::default()
};
Expand Down Expand Up @@ -375,8 +367,6 @@ impl InMemorySubscriber {

async fn invoke_unsubscribe(&self, topic: &UUri) -> Result<(), RegistrationError> {
let request = UnsubscribeRequest {
subscriber: Some(self.subscriber_info()).into(),
topic: Some(topic.to_owned()).into(),
..Default::default()
};
self.usubscription
Expand Down Expand Up @@ -628,7 +618,7 @@ mod tests {

let subscriber = InMemorySubscriber {
transport: Arc::new(MockTransport::new()),
uri_provider: new_uri_provider(),
_uri_provider: new_uri_provider(),
usubscription: Arc::new(MockUSubscription::new()),
notifier: Arc::new(notifier),
subscription_change_listener,
Expand Down

0 comments on commit a867e52

Please sign in to comment.