22
33mod spin;
44
5- use crate :: spin:: SpinRedisExecutor ;
5+ use std:: { collections:: HashMap , sync:: Arc } ;
6+
67use anyhow:: Result ;
78use async_trait:: async_trait;
89use futures:: StreamExt ;
910use redis:: { Client , ConnectionLike } ;
1011use spin_manifest:: { ComponentMap , RedisConfig , RedisTriggerConfiguration , TriggerConfig } ;
1112use spin_redis:: SpinRedisData ;
1213use spin_trigger:: { cli:: NoArgs , TriggerExecutor } ;
13- use std:: { collections:: HashMap , sync:: Arc } ;
14+
15+ use crate :: spin:: SpinRedisExecutor ;
1416
1517wit_bindgen_wasmtime:: import!( { paths: [ "../../wit/ephemeral/spin-redis.wit" ] , async : * } ) ;
1618
@@ -80,14 +82,14 @@ impl TriggerExecutor for RedisTrigger {
8082 async fn run ( self , _config : Self :: RunConfig ) -> Result < ( ) > {
8183 let address = self . trigger_config . address . as_str ( ) ;
8284
83- log :: info!( "Connecting to Redis server at {}" , address) ;
85+ tracing :: info!( "Connecting to Redis server at {}" , address) ;
8486 let mut client = Client :: open ( address. to_string ( ) ) ?;
8587 let mut pubsub = client. get_async_connection ( ) . await ?. into_pubsub ( ) ;
8688
8789 // Subscribe to channels
8890 for ( subscription, idx) in self . subscriptions . iter ( ) {
8991 let name = & self . engine . config . components [ * idx] . id ;
90- log :: info!(
92+ tracing :: info!(
9193 "Subscribed component #{} ({}) to channel: {}" ,
9294 idx,
9395 name,
@@ -101,9 +103,9 @@ impl TriggerExecutor for RedisTrigger {
101103 match stream. next ( ) . await {
102104 Some ( msg) => drop ( self . handle ( msg) . await ) ,
103105 None => {
104- log :: trace!( "Empty message" ) ;
106+ tracing :: trace!( "Empty message" ) ;
105107 if !client. check_connection ( ) {
106- log :: info!( "No Redis connection available" ) ;
108+ tracing :: info!( "No Redis connection available" ) ;
107109 break Ok ( ( ) ) ;
108110 }
109111 }
@@ -116,7 +118,7 @@ impl RedisTrigger {
116118 // Handle the message.
117119 async fn handle ( & self , msg : redis:: Msg ) -> Result < ( ) > {
118120 let channel = msg. get_channel_name ( ) ;
119- log :: info!( "Received message on channel {:?}" , channel) ;
121+ tracing :: info!( "Received message on channel {:?}" , channel) ;
120122
121123 if let Some ( idx) = self . subscriptions . get ( channel) . copied ( ) {
122124 let component = & self . engine . config . components [ idx] ;
@@ -134,7 +136,7 @@ impl RedisTrigger {
134136
135137 match executor {
136138 spin_manifest:: RedisExecutor :: Spin => {
137- log :: trace!( "Executing Spin Redis component {}" , component. id) ;
139+ tracing :: trace!( "Executing Spin Redis component {}" , component. id) ;
138140 let executor = SpinRedisExecutor ;
139141 executor
140142 . execute (
@@ -148,7 +150,7 @@ impl RedisTrigger {
148150 }
149151 } ;
150152 } else {
151- log :: debug!( "No subscription found for {:?}" , channel) ;
153+ tracing :: debug!( "No subscription found for {:?}" , channel) ;
152154 }
153155
154156 Ok ( ( ) )
0 commit comments