@@ -223,13 +223,13 @@ impl NetworkHandler {
223
223
}
224
224
Status :: Subscribed => {
225
225
for command in & msg. commands {
226
- if let "UNSUBSCRIBE" | "PUNSUBSCRIBE" | "SUNSUBSCRIBE" = command. name {
227
- let subscription_type = match command . name {
228
- "UNSUBSCRIBE " => SubscriptionType :: Channel ,
229
- "PUNSUBSCRIBE " => SubscriptionType :: Pattern ,
230
- "SUNSUBSCRIBE" => SubscriptionType :: ShardChannel ,
231
- _ => unreachable ! ( ) ,
232
- } ;
226
+ let subscription_type = match command. name {
227
+ "UNSUBSCRIBE" => Some ( SubscriptionType :: Channel ) ,
228
+ "PUNSUBSCRIBE " => Some ( SubscriptionType :: Pattern ) ,
229
+ "SUNSUBSCRIBE " => Some ( SubscriptionType :: ShardChannel ) ,
230
+ _ => None ,
231
+ } ;
232
+ if let Some ( subscription_type ) = subscription_type {
233
233
self . pending_unsubscriptions . push_back (
234
234
command
235
235
. args
@@ -568,16 +568,34 @@ impl NetworkHandler {
568
568
| RefPubSubMessage :: SMessage ( channel_or_pattern, _) => {
569
569
match self . subscriptions . get_mut ( channel_or_pattern) {
570
570
Some ( ( _subscription_type, pub_sub_sender) ) => {
571
- if let Err ( e) = pub_sub_sender. send ( value) . await {
572
- warn ! (
573
- "[{}] Cannot send pub/sub message to caller: {e}" ,
574
- self . tag
575
- ) ;
571
+ if let Err ( e) = pub_sub_sender. unbounded_send ( value) {
572
+ let error_desc = e. to_string ( ) ;
573
+ if let Ok ( ref_value) = & e. into_inner ( ) {
574
+ if let Some ( pub_sub_message) =
575
+ RefPubSubMessage :: from_resp ( ref_value)
576
+ {
577
+ if let RefPubSubMessage :: Message (
578
+ channel_or_pattern,
579
+ _,
580
+ )
581
+ | RefPubSubMessage :: SMessage (
582
+ channel_or_pattern,
583
+ _,
584
+ ) = pub_sub_message
585
+ {
586
+ warn ! (
587
+ "[{}] Cannot send pub/sub message to caller from channel `{}`: {error_desc}" ,
588
+ self . tag,
589
+ String :: from_utf8_lossy( channel_or_pattern)
590
+ ) ;
591
+ }
592
+ }
593
+ }
576
594
}
577
595
}
578
596
None => {
579
597
error ! (
580
- "[{}] Unexpected message on channel '{:?}' " ,
598
+ "[{}] Unexpected message on channel `{}` " ,
581
599
self . tag,
582
600
String :: from_utf8_lossy( channel_or_pattern)
583
601
) ;
@@ -600,7 +618,7 @@ impl NetworkHandler {
600
618
{
601
619
return Some ( Err ( Error :: Client (
602
620
format ! (
603
- "There is already a subscription on channel '{}' " ,
621
+ "There is already a subscription on channel `{}` " ,
604
622
String :: from_utf8_lossy( channel_or_pattern)
605
623
)
606
624
. to_string ( ) ,
@@ -612,14 +630,14 @@ impl NetworkHandler {
612
630
}
613
631
} else {
614
632
error ! (
615
- "[{}] Unexpected subscription confirmation on channel '{}' " ,
633
+ "[{}] Unexpected subscription confirmation on channel `{}` " ,
616
634
self . tag,
617
635
String :: from_utf8_lossy( channel_or_pattern)
618
636
) ;
619
637
}
620
638
} else {
621
639
error ! (
622
- "[{}] Cannot find pending subscription for channel '{}' " ,
640
+ "[{}] Cannot find pending subscription for channel `{}` " ,
623
641
self . tag,
624
642
String :: from_utf8_lossy( channel_or_pattern)
625
643
) ;
@@ -634,7 +652,7 @@ impl NetworkHandler {
634
652
if remaining. len ( ) > 1 {
635
653
if remaining. remove ( channel_or_pattern) . is_none ( ) {
636
654
error ! (
637
- "[{}] Cannot find channel or pattern to remove: {} " ,
655
+ "[{}] Cannot find channel or pattern to remove: `{}` " ,
638
656
self . tag,
639
657
String :: from_utf8_lossy( channel_or_pattern)
640
658
) ;
@@ -645,15 +663,15 @@ impl NetworkHandler {
645
663
let Some ( mut remaining) = self . pending_unsubscriptions . pop_front ( )
646
664
else {
647
665
error ! (
648
- "[{}] Cannot find channel or pattern to remove: {} " ,
666
+ "[{}] Cannot find channel or pattern to remove: `{}` " ,
649
667
self . tag,
650
668
String :: from_utf8_lossy( channel_or_pattern)
651
669
) ;
652
670
return None ;
653
671
} ;
654
672
if remaining. remove ( channel_or_pattern) . is_none ( ) {
655
673
error ! (
656
- "[{}] Cannot find channel or pattern to remove: {} " ,
674
+ "[{}] Cannot find channel or pattern to remove: `{}` " ,
657
675
self . tag,
658
676
String :: from_utf8_lossy( channel_or_pattern)
659
677
) ;
@@ -677,7 +695,7 @@ impl NetworkHandler {
677
695
}
678
696
None => {
679
697
error ! (
680
- "[{}] Unexpected message on channel '{}' for pattern '{}' " ,
698
+ "[{}] Unexpected message on channel `{}` for pattern `{}` " ,
681
699
self . tag,
682
700
String :: from_utf8_lossy( channel) ,
683
701
String :: from_utf8_lossy( pattern)
0 commit comments