2
2
3
3
mod spin;
4
4
5
- use crate :: spin:: SpinRedisExecutor ;
5
+ use std:: { collections:: HashMap , sync:: Arc } ;
6
+
6
7
use anyhow:: Result ;
7
8
use async_trait:: async_trait;
8
9
use futures:: StreamExt ;
9
10
use redis:: { Client , ConnectionLike } ;
10
11
use spin_manifest:: { ComponentMap , RedisConfig , RedisTriggerConfiguration , TriggerConfig } ;
11
12
use spin_redis:: SpinRedisData ;
12
13
use spin_trigger:: { cli:: NoArgs , TriggerExecutor } ;
13
- use std:: { collections:: HashMap , sync:: Arc } ;
14
+
15
+ use crate :: spin:: SpinRedisExecutor ;
14
16
15
17
wit_bindgen_wasmtime:: import!( { paths: [ "../../wit/ephemeral/spin-redis.wit" ] , async : * } ) ;
16
18
@@ -80,14 +82,14 @@ impl TriggerExecutor for RedisTrigger {
80
82
async fn run ( self , _config : Self :: RunConfig ) -> Result < ( ) > {
81
83
let address = self . trigger_config . address . as_str ( ) ;
82
84
83
- log :: info!( "Connecting to Redis server at {}" , address) ;
85
+ tracing :: info!( "Connecting to Redis server at {}" , address) ;
84
86
let mut client = Client :: open ( address. to_string ( ) ) ?;
85
87
let mut pubsub = client. get_async_connection ( ) . await ?. into_pubsub ( ) ;
86
88
87
89
// Subscribe to channels
88
90
for ( subscription, idx) in self . subscriptions . iter ( ) {
89
91
let name = & self . engine . config . components [ * idx] . id ;
90
- log :: info!(
92
+ tracing :: info!(
91
93
"Subscribed component #{} ({}) to channel: {}" ,
92
94
idx,
93
95
name,
@@ -101,9 +103,9 @@ impl TriggerExecutor for RedisTrigger {
101
103
match stream. next ( ) . await {
102
104
Some ( msg) => drop ( self . handle ( msg) . await ) ,
103
105
None => {
104
- log :: trace!( "Empty message" ) ;
106
+ tracing :: trace!( "Empty message" ) ;
105
107
if !client. check_connection ( ) {
106
- log :: info!( "No Redis connection available" ) ;
108
+ tracing :: info!( "No Redis connection available" ) ;
107
109
break Ok ( ( ) ) ;
108
110
}
109
111
}
@@ -116,7 +118,7 @@ impl RedisTrigger {
116
118
// Handle the message.
117
119
async fn handle ( & self , msg : redis:: Msg ) -> Result < ( ) > {
118
120
let channel = msg. get_channel_name ( ) ;
119
- log :: info!( "Received message on channel {:?}" , channel) ;
121
+ tracing :: info!( "Received message on channel {:?}" , channel) ;
120
122
121
123
if let Some ( idx) = self . subscriptions . get ( channel) . copied ( ) {
122
124
let component = & self . engine . config . components [ idx] ;
@@ -134,7 +136,7 @@ impl RedisTrigger {
134
136
135
137
match executor {
136
138
spin_manifest:: RedisExecutor :: Spin => {
137
- log :: trace!( "Executing Spin Redis component {}" , component. id) ;
139
+ tracing :: trace!( "Executing Spin Redis component {}" , component. id) ;
138
140
let executor = SpinRedisExecutor ;
139
141
executor
140
142
. execute (
@@ -148,7 +150,7 @@ impl RedisTrigger {
148
150
}
149
151
} ;
150
152
} else {
151
- log :: debug!( "No subscription found for {:?}" , channel) ;
153
+ tracing :: debug!( "No subscription found for {:?}" , channel) ;
152
154
}
153
155
154
156
Ok ( ( ) )
0 commit comments