@@ -24,24 +24,16 @@ use up_rust::{
24
24
UAttributes ,
25
25
} ;
26
26
27
- use crate :: {
28
- helpers, usubscription,
29
- { notification_manager:: NotificationEvent , subscription_manager:: SubscriptionEvent } ,
30
- } ;
27
+ use crate :: { helpers, subscription_manager:: SubscriptionEvent , usubscription} ;
31
28
32
29
pub ( crate ) struct SubscriptionRequestHandler {
33
30
subscription_sender : Sender < SubscriptionEvent > ,
34
- notification_sender : Sender < NotificationEvent > ,
35
31
}
36
32
37
33
impl SubscriptionRequestHandler {
38
- pub ( crate ) fn new (
39
- subscription_sender : Sender < SubscriptionEvent > ,
40
- notification_sender : Sender < NotificationEvent > ,
41
- ) -> Self {
34
+ pub ( crate ) fn new ( subscription_sender : Sender < SubscriptionEvent > ) -> Self {
42
35
Self {
43
36
subscription_sender,
44
- notification_sender,
45
37
}
46
38
}
47
39
}
@@ -108,25 +100,6 @@ impl RequestHandler for SubscriptionRequestHandler {
108
100
) ) ;
109
101
} ;
110
102
111
- // Notify update channel
112
- let ( respond_to, receive_from) = oneshot:: channel :: < ( ) > ( ) ;
113
- if let Err ( e) = self
114
- . notification_sender
115
- . send ( NotificationEvent :: StateChange {
116
- subscriber : source. clone ( ) ,
117
- topic : subscription_request. topic . clone ( ) . unwrap_or_default ( ) ,
118
- status : status. clone ( ) ,
119
- respond_to,
120
- } )
121
- . await
122
- {
123
- error ! ( "Error initiating subscription-change update notification: {e}" ) ;
124
- }
125
- if let Err ( e) = receive_from. await {
126
- // Not returning an error here, as update notification is not a core concern wrt the actual subscription management
127
- warn ! ( "Error sending subscription-change update notification: {e}" ) ;
128
- } ;
129
-
130
103
// Build and return result
131
104
let response = SubscriptionResponse {
132
105
topic : Some ( subscription_request. topic . unwrap_or_default ( ) ) . into ( ) ,
@@ -164,12 +137,9 @@ mod tests {
164
137
165
138
let ( subscription_sender, mut subscription_receiver) =
166
139
mpsc:: channel :: < SubscriptionEvent > ( 1 ) ;
167
- let ( notification_sender, mut notification_receiver) =
168
- mpsc:: channel :: < NotificationEvent > ( 1 ) ;
169
140
170
141
// create and spawn off handler, to make all the asnync goodness work
171
- let request_handler =
172
- SubscriptionRequestHandler :: new ( subscription_sender, notification_sender) ;
142
+ let request_handler = SubscriptionRequestHandler :: new ( subscription_sender) ;
173
143
tokio:: spawn ( async move {
174
144
let result = request_handler
175
145
. handle_request (
@@ -207,28 +177,6 @@ mod tests {
207
177
}
208
178
_ => panic ! ( "Wrong event type" ) ,
209
179
}
210
-
211
- // validate notification manager interaction
212
- let notification_event = notification_receiver. recv ( ) . await . unwrap ( ) ;
213
- match notification_event {
214
- NotificationEvent :: StateChange {
215
- subscriber,
216
- topic,
217
- status,
218
- respond_to : _,
219
- } => {
220
- assert_eq ! ( subscriber, test_lib:: helpers:: subscriber_uri1( ) ) ;
221
- assert_eq ! ( topic, test_lib:: helpers:: local_topic1_uri( ) ) ;
222
- assert_eq ! (
223
- status,
224
- SubscriptionStatus {
225
- state: State :: SUBSCRIBED . into( ) ,
226
- ..Default :: default ( )
227
- }
228
- ) ;
229
- }
230
- _ => panic ! ( "Wrong event type" ) ,
231
- }
232
180
}
233
181
234
182
#[ tokio:: test]
@@ -245,11 +193,9 @@ mod tests {
245
193
} ;
246
194
247
195
let ( subscription_sender, _) = mpsc:: channel :: < SubscriptionEvent > ( 1 ) ;
248
- let ( notification_sender, _) = mpsc:: channel :: < NotificationEvent > ( 1 ) ;
249
196
250
197
// create handler and perform tested operation
251
- let request_handler =
252
- SubscriptionRequestHandler :: new ( subscription_sender, notification_sender) ;
198
+ let request_handler = SubscriptionRequestHandler :: new ( subscription_sender) ;
253
199
254
200
let result = request_handler
255
201
. handle_request (
@@ -276,11 +222,9 @@ mod tests {
276
222
let request_payload = UPayload :: try_from_protobuf ( subscribe_request. clone ( ) ) . unwrap ( ) ;
277
223
278
224
let ( subscription_sender, _) = mpsc:: channel :: < SubscriptionEvent > ( 1 ) ;
279
- let ( notification_sender, _) = mpsc:: channel :: < NotificationEvent > ( 1 ) ;
280
225
281
226
// create handler and perform tested operation
282
- let request_handler =
283
- SubscriptionRequestHandler :: new ( subscription_sender, notification_sender) ;
227
+ let request_handler = SubscriptionRequestHandler :: new ( subscription_sender) ;
284
228
285
229
let result = request_handler
286
230
. handle_request (
@@ -308,11 +252,9 @@ mod tests {
308
252
} ;
309
253
310
254
let ( subscription_sender, _) = mpsc:: channel :: < SubscriptionEvent > ( 1 ) ;
311
- let ( notification_sender, _) = mpsc:: channel :: < NotificationEvent > ( 1 ) ;
312
255
313
256
// create handler and perform tested operation
314
- let request_handler =
315
- SubscriptionRequestHandler :: new ( subscription_sender, notification_sender) ;
257
+ let request_handler = SubscriptionRequestHandler :: new ( subscription_sender) ;
316
258
317
259
let result = request_handler
318
260
. handle_request ( RESOURCE_ID_SUBSCRIBE , & message_attributes, None )
@@ -339,11 +281,9 @@ mod tests {
339
281
} ;
340
282
341
283
let ( subscription_sender, _) = mpsc:: channel :: < SubscriptionEvent > ( 1 ) ;
342
- let ( notification_sender, _) = mpsc:: channel :: < NotificationEvent > ( 1 ) ;
343
284
344
285
// create handler and perform tested operation
345
- let request_handler =
346
- SubscriptionRequestHandler :: new ( subscription_sender, notification_sender) ;
286
+ let request_handler = SubscriptionRequestHandler :: new ( subscription_sender) ;
347
287
348
288
let result = request_handler
349
289
. handle_request (
@@ -385,11 +325,9 @@ mod tests {
385
325
386
326
let ( subscription_sender, mut subscription_receiver) =
387
327
mpsc:: channel :: < SubscriptionEvent > ( 1 ) ;
388
- let ( notification_sender, _) = mpsc:: channel :: < NotificationEvent > ( 1 ) ;
389
328
390
329
// create and spawn off handler, to make all the asnync goodness work
391
- let request_handler =
392
- SubscriptionRequestHandler :: new ( subscription_sender, notification_sender) ;
330
+ let request_handler = SubscriptionRequestHandler :: new ( subscription_sender) ;
393
331
tokio:: spawn ( async move {
394
332
let result = request_handler
395
333
. handle_request (
@@ -450,11 +388,9 @@ mod tests {
450
388
} ;
451
389
452
390
let ( subscription_sender, _) = mpsc:: channel :: < SubscriptionEvent > ( 1 ) ;
453
- let ( notification_sender, _) = mpsc:: channel :: < NotificationEvent > ( 1 ) ;
454
391
455
392
// create handler and perform tested operation
456
- let request_handler =
457
- SubscriptionRequestHandler :: new ( subscription_sender, notification_sender) ;
393
+ let request_handler = SubscriptionRequestHandler :: new ( subscription_sender) ;
458
394
459
395
let result = request_handler
460
396
. handle_request (
0 commit comments