@@ -685,6 +685,7 @@ def telemetry(self, api: TelemetryAPI, dehydration_hooks=None,
685685                     Response (self , "telemetry" , hydration_hooks , ** handlers ),
686686                     dehydration_hooks = dehydration_hooks )
687687
688+ 
688689class  AsyncBolt5x5 (AsyncBolt5x4 ):
689690
690691    PROTOCOL_VERSION  =  Version (5 , 5 )
@@ -783,7 +784,7 @@ def begin(self, mode=None, bookmarks=None, metadata=None, timeout=None,
783784        ("CURRENT_SCHEMA" , "/" ),
784785    )
785786
786-     def  _make_enrich_diagnostic_record_handler (self , wrapped_handler = None ):
787+     def  _make_enrich_statuses_handler (self , wrapped_handler = None ):
787788        async  def  handler (metadata ):
788789            def  enrich (metadata_ ):
789790                if  not  isinstance (metadata_ , dict ):
@@ -794,6 +795,7 @@ def enrich(metadata_):
794795                for  status  in  statuses :
795796                    if  not  isinstance (status , dict ):
796797                        continue 
798+                     status ["description" ] =  status .get ("status_description" )
797799                    diag_record  =  status .setdefault ("diagnostic_record" , {})
798800                    if  not  isinstance (diag_record , dict ):
799801                        log .info ("[#%04X]  _: <CONNECTION> Server supplied an " 
@@ -810,14 +812,44 @@ def enrich(metadata_):
810812
811813    def  discard (self , n = - 1 , qid = - 1 , dehydration_hooks = None ,
812814                hydration_hooks = None , ** handlers ):
813-         handlers ["on_success" ] =  self ._make_enrich_diagnostic_record_handler (
815+         handlers ["on_success" ] =  self ._make_enrich_statuses_handler (
814816            wrapped_handler = handlers .get ("on_success" )
815817        )
816818        super ().discard (n , qid , dehydration_hooks , hydration_hooks , ** handlers )
817819
818820    def  pull (self , n = - 1 , qid = - 1 , dehydration_hooks = None , hydration_hooks = None ,
819821             ** handlers ):
820-         handlers ["on_success" ] =  self ._make_enrich_diagnostic_record_handler (
822+         handlers ["on_success" ] =  self ._make_enrich_statuses_handler (
821823            wrapped_handler = handlers .get ("on_success" )
822824        )
823825        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