11use crate :: traits:: IdentifiableFlow ;
22use async_nats:: jetstream:: kv:: Config ;
3+ use code0_flow:: flow_validator:: verify_flow;
34use futures_lite:: StreamExt ;
45use prost:: Message ;
56use tucana:: shared:: { ExecutionFlow , ValidationFlow , Value } ;
6- use code0_flow:: flow_validator:: verify_flow;
77
88pub struct AdapterStore {
99 client : async_nats:: Client ,
@@ -30,10 +30,11 @@ impl AdapterStore {
3030 bucket : bucket. clone ( ) ,
3131 ..Default :: default ( )
3232 } )
33- . await {
33+ . await
34+ {
3435 Ok ( _) => {
3536 log:: info!( "Successfully created NATS bucket" ) ;
36- } ,
37+ }
3738 Err ( err) => panic ! ( "Failed to create NATS bucket: {:?}" , err) ,
3839 }
3940
@@ -79,17 +80,16 @@ impl AdapterStore {
7980 } ;
8081
8182 while let Ok ( Some ( key) ) = keys. try_next ( ) . await {
82-
8383 if !Self :: is_matching_key ( & pattern, & key) {
8484 continue ;
8585 }
8686
8787 if let Ok ( Some ( bytes) ) = self . kv . get ( key) . await {
8888 let decoded_flow = ValidationFlow :: decode ( bytes) ;
89- if let Ok ( flow) = decoded_flow {
90- if id. identify ( & flow) {
91- collector . push ( flow ) ;
92- }
89+ if let Ok ( flow) = decoded_flow
90+ && id. identify ( & flow)
91+ {
92+ collector . push ( flow . clone ( ) ) ;
9393 } ;
9494 }
9595 }
@@ -132,9 +132,7 @@ impl AdapterStore {
132132
133133 match result {
134134 Ok ( message) => match Value :: decode ( message. payload ) {
135- Ok ( value) => {
136- Some ( value)
137- }
135+ Ok ( value) => Some ( value) ,
138136 Err ( err) => {
139137 log:: error!( "Failed to decode response from NATS server: {:?}" , err) ;
140138 None
@@ -151,7 +149,7 @@ impl AdapterStore {
151149 ExecutionFlow {
152150 flow_id : flow. flow_id ,
153151 starting_node : flow. starting_node ,
154- input_value : input_value ,
152+ input_value,
155153 }
156154 }
157155
0 commit comments