@@ -685,6 +685,7 @@ def telemetry(self, api: TelemetryAPI, dehydration_hooks=None,
685
685
Response (self , "telemetry" , hydration_hooks , ** handlers ),
686
686
dehydration_hooks = dehydration_hooks )
687
687
688
+
688
689
class AsyncBolt5x5 (AsyncBolt5x4 ):
689
690
690
691
PROTOCOL_VERSION = Version (5 , 5 )
@@ -783,7 +784,7 @@ def begin(self, mode=None, bookmarks=None, metadata=None, timeout=None,
783
784
("CURRENT_SCHEMA" , "/" ),
784
785
)
785
786
786
- def _make_enrich_diagnostic_record_handler (self , wrapped_handler = None ):
787
+ def _make_enrich_statuses_handler (self , wrapped_handler = None ):
787
788
async def handler (metadata ):
788
789
def enrich (metadata_ ):
789
790
if not isinstance (metadata_ , dict ):
@@ -794,6 +795,7 @@ def enrich(metadata_):
794
795
for status in statuses :
795
796
if not isinstance (status , dict ):
796
797
continue
798
+ status ["description" ] = status .get ("status_description" )
797
799
diag_record = status .setdefault ("diagnostic_record" , {})
798
800
if not isinstance (diag_record , dict ):
799
801
log .info ("[#%04X] _: <CONNECTION> Server supplied an "
@@ -810,14 +812,44 @@ def enrich(metadata_):
810
812
811
813
def discard (self , n = - 1 , qid = - 1 , dehydration_hooks = None ,
812
814
hydration_hooks = None , ** handlers ):
813
- handlers ["on_success" ] = self ._make_enrich_diagnostic_record_handler (
815
+ handlers ["on_success" ] = self ._make_enrich_statuses_handler (
814
816
wrapped_handler = handlers .get ("on_success" )
815
817
)
816
818
super ().discard (n , qid , dehydration_hooks , hydration_hooks , ** handlers )
817
819
818
820
def pull (self , n = - 1 , qid = - 1 , dehydration_hooks = None , hydration_hooks = None ,
819
821
** handlers ):
820
- handlers ["on_success" ] = self ._make_enrich_diagnostic_record_handler (
822
+ handlers ["on_success" ] = self ._make_enrich_statuses_handler (
821
823
wrapped_handler = handlers .get ("on_success" )
822
824
)
823
825
super ().pull (n , qid , dehydration_hooks , hydration_hooks , ** handlers )
826
+
827
+
828
+ class AsyncBolt5x6 (AsyncBolt5x5 ):
829
+
830
+ PROTOCOL_VERSION = Version (5 , 6 )
831
+
832
+ def _make_enrich_statuses_handler (self , wrapped_handler = None ):
833
+ async def handler (metadata ):
834
+ def enrich (metadata_ ):
835
+ if not isinstance (metadata_ , dict ):
836
+ return
837
+ statuses = metadata_ .get ("statuses" )
838
+ if not isinstance (statuses , list ):
839
+ return
840
+ for status in statuses :
841
+ if not isinstance (status , dict ):
842
+ continue
843
+ diag_record = status .setdefault ("diagnostic_record" , {})
844
+ if not isinstance (diag_record , dict ):
845
+ log .info ("[#%04X] _: <CONNECTION> Server supplied an "
846
+ "invalid diagnostic record (%r)." ,
847
+ self .local_port , diag_record )
848
+ continue
849
+ for key , value in self .DEFAULT_DIAGNOSTIC_RECORD :
850
+ diag_record .setdefault (key , value )
851
+
852
+ enrich (metadata )
853
+ await AsyncUtil .callback (wrapped_handler , metadata )
854
+
855
+ return handler
0 commit comments