@@ -43,11 +43,6 @@ use crate::{
4343// via tokio mpsc channel. This design allows to forgo the use of any synhronization primitives on the subscription-tracking container
4444// data types, as any access is coordinated/serialized via the Event selection loop.
4545
46- // Maximum number of `Subscriber` entries to be returned in a `FetchSusbcriptions´ operation.
47- const UP_MAX_FETCH_SUBSCRIBERS_LEN : usize = 100 ;
48- // Maximum number of `Subscriber` entries to be returned in a `FetchSusbcriptions´ operation.
49- const UP_MAX_FETCH_SUBSCRIPTIONS_LEN : usize = 100 ;
50-
5146// Queue size of message channel for internal commands - like subscription status change messages or subscription expiration commands.
5247const INTERNAL_COMMAND_BUFFER_SIZE : usize = 128 ;
5348
@@ -68,9 +63,6 @@ pub(crate) struct SubscriptionEntry {
6863 pub ( crate ) status : SubscriptionStatus ,
6964}
7065
71- pub ( crate ) type SubscribersResponse = ( Vec < SubscriberUUri > , bool ) ; // List of subscribers, boolean flag stating if there exist more entries than contained in list
72- pub ( crate ) type SubscriptionsResponse = ( Vec < SubscriptionEntry > , bool ) ; // List of subscriber entries, boolean flag stating if there exist more entries than contained in list
73-
7466// This is the 'outside API' of subscription manager, it includes some events that are only to be used in (and only enabled for) testing.
7567#[ derive( Debug ) ]
7668pub ( crate ) enum SubscriptionEvent {
@@ -87,13 +79,11 @@ pub(crate) enum SubscriptionEvent {
8779 } ,
8880 FetchSubscribers {
8981 topic : TopicUUri ,
90- offset : Option < u32 > ,
91- respond_to : oneshot:: Sender < SubscribersResponse > , // return list of subscribers and flag indicating whether there are more
82+ respond_to : oneshot:: Sender < Vec < SubscriberUUri > > ,
9283 } ,
9384 FetchSubscriptions {
9485 request : RequestKind ,
95- offset : Option < u32 > ,
96- respond_to : oneshot:: Sender < SubscriptionsResponse > , // return list of Subscriptions and flag indicating whether there are more
86+ respond_to : oneshot:: Sender < Vec < SubscriptionEntry > > ,
9787 } ,
9888 // Purely for use during testing: get copy of current topic-subscriper ledger
9989 #[ cfg( test) ]
@@ -281,26 +271,23 @@ pub(crate) async fn handle_message(
281271 }
282272 }
283273 }
284- SubscriptionEvent :: FetchSubscribers {
285- topic,
286- offset,
287- respond_to,
288- } => match fetch_subscribers ( & subscriptions, topic, offset) {
289- // [impl->req~usubscription-fetch-subscribers~1]
290- Ok ( result) => {
291- if respond_to. send ( result) . is_err ( ) {
292- error ! ( "Problem with internal communication" ) ;
274+ SubscriptionEvent :: FetchSubscribers { topic, respond_to } => {
275+ match fetch_subscribers ( & subscriptions, topic) {
276+ // [impl->req~usubscription-fetch-subscribers~1]
277+ Ok ( result) => {
278+ if respond_to. send ( result) . is_err ( ) {
279+ error ! ( "Problem with internal communication" ) ;
280+ }
281+ }
282+ Err ( e) => {
283+ panic ! ( "Persistency failure {e}" )
293284 }
294285 }
295- Err ( e) => {
296- panic ! ( "Persistency failure {e}" )
297- }
298- } ,
286+ }
299287 SubscriptionEvent :: FetchSubscriptions {
300288 request,
301- offset,
302289 respond_to,
303- } => match fetch_subscriptions ( & subscriptions, & remote_topics, request, offset ) {
290+ } => match fetch_subscriptions ( & subscriptions, & remote_topics, request) {
304291 Ok ( result) => {
305292 if respond_to. send ( result) . is_err ( ) {
306293 error ! ( "Problem with internal communication" ) ;
@@ -541,37 +528,19 @@ fn remove_subscription(
541528fn fetch_subscribers (
542529 topic_subscribers : & persistency:: SubscriptionsStore ,
543530 topic : TopicUUri ,
544- offset : Option < u32 > ,
545- ) -> Result < SubscribersResponse , persistency:: PersistencyError > {
531+ ) -> Result < Vec < SubscriberUUri > , persistency:: PersistencyError > {
546532 // This will get *every* client that subscribed to `topic` - no matter whether (in the case of remote subscriptions)
547533 // the remote topic is already fully SUBSCRIBED, of still SUSBCRIBED_PENDING
548- let mut subscribers = topic_subscribers. get_topic_subscribers ( & topic) ?;
549-
550- // [impl->req~usubscription-fetch-subscribers-offset~1]
551- if let Some ( offset) = offset {
552- subscribers. drain ( ..offset as usize ) ;
553- }
554-
555- // split up result list, to make sense of has_more_records field
556- // [impl->req~usubscription-fetch-subscribers-has-more-records~1]
557- let has_more = if subscribers. len ( ) > UP_MAX_FETCH_SUBSCRIBERS_LEN {
558- subscribers. truncate ( UP_MAX_FETCH_SUBSCRIBERS_LEN ) ;
559- true
560- } else {
561- false
562- } ;
563-
564- Ok ( ( subscribers, has_more) )
534+ topic_subscribers. get_topic_subscribers ( & topic)
565535}
566536
567537// Fetch all subscriptions of a topic or subscribers
568538fn fetch_subscriptions (
569539 topic_subscribers : & persistency:: SubscriptionsStore ,
570540 remote_topics : & persistency:: RemoteTopicsStore ,
571541 request : RequestKind ,
572- offset : Option < u32 > ,
573- ) -> Result < SubscriptionsResponse , persistency:: PersistencyError > {
574- let mut results: Vec < SubscriptionEntry > = match request {
542+ ) -> Result < Vec < SubscriptionEntry > , persistency:: PersistencyError > {
543+ let results: Vec < SubscriptionEntry > = match request {
575544 // [impl->req~usubscription-fetch-subscriptions-by-subscriber~1]
576545 RequestKind :: Subscriber ( subscriber) => topic_subscribers
577546 . get_subscriber_topics ( & subscriber) ?
@@ -609,20 +578,7 @@ fn fetch_subscriptions(
609578 . collect ( ) ,
610579 } ;
611580
612- // [impl->req~usubscription-fetch-subscriptions-offset~1]
613- if let Some ( offset) = offset {
614- results. drain ( ..offset as usize ) ;
615- }
616-
617- // split up result list, to make sense of has_more_records field
618- // [impl->req~usubscription-fetch-subscriptions-has-more-records~1]
619- let mut has_more = false ;
620- if results. len ( ) > UP_MAX_FETCH_SUBSCRIPTIONS_LEN {
621- results. truncate ( UP_MAX_FETCH_SUBSCRIPTIONS_LEN ) ;
622- has_more = true ;
623- }
624-
625- Ok ( ( results, has_more) )
581+ Ok ( results)
626582}
627583
628584// Perform remote topic subscription
0 commit comments