diff --git a/examples/demo/config/development.yaml b/examples/demo/config/development.yaml index f932a6338..f49d49bdc 100644 --- a/examples/demo/config/development.yaml +++ b/examples/demo/config/development.yaml @@ -124,8 +124,8 @@ database: # Recreating schema when application loaded. This is a dangerous operation, make sure that you using this flag only on dev environments or test mode dangerously_recreate: false -# Redis Configuration -redis: +# Queue Configuration +queue: # Redis connection URI uri: {{get_env(name="REDIS_URL", default="redis://127.0.0.1")}} # Dangerously flush all data in Redis on startup. dangerous operation, make sure that you using this flag only on dev environments or test mode diff --git a/examples/demo/config/test.yaml b/examples/demo/config/test.yaml index da7dc833f..3734579b6 100644 --- a/examples/demo/config/test.yaml +++ b/examples/demo/config/test.yaml @@ -116,8 +116,8 @@ database: # Recreating schema when application loaded. This is a dangerous operation, make sure that you using this flag only on dev environments or test mode dangerously_recreate: true -# Redis Configuration -redis: +# Queue Configuration +queue: # Redis connection URI uri: {{get_env(name="REDIS_URL", default="redis://127.0.0.1")}} # Dangerously flush all data in Redis on startup. dangerous operation, make sure that you using this flag only on dev environments or test mode diff --git a/examples/demo/config/teste2e.yaml b/examples/demo/config/teste2e.yaml index 3679cb8fb..e0e9cae38 100644 --- a/examples/demo/config/teste2e.yaml +++ b/examples/demo/config/teste2e.yaml @@ -95,8 +95,8 @@ database: # Recreating schema when application loaded. This is a dangerous operation, make sure that you using this flag only on dev environments or test mode dangerously_recreate: true -# Redis Configuration -redis: +# Queue Configuration +queue: # Redis connection URI uri: {{get_env(name="APP_REDIS_URI", default="redis://127.0.0.1")}} # Dangerously flush all data in Redis on startup. dangerous operation, make sure that you using this flag only on dev environments or test mode diff --git a/src/app.rs b/src/app.rs index acb0d35c2..0dab04631 100644 --- a/src/app.rs +++ b/src/app.rs @@ -41,8 +41,8 @@ pub struct AppContext { #[cfg(feature = "with-db")] /// A database connection used by the application. pub db: DatabaseConnection, - /// An optional connection pool for Redis, for worker tasks - pub redis: Option>, + /// An optional connection pool for Queue, for worker tasks + pub queue: Option>, /// Configuration settings for the application pub config: Config, /// An optional email sender component that can be used to send email. diff --git a/src/boot.rs b/src/boot.rs index c0d4f54a5..e1289c692 100644 --- a/src/boot.rs +++ b/src/boot.rs @@ -200,13 +200,11 @@ pub async fn create_context(environment: &Environment) -> Result( let app_context = create_context::(environment).await?; db::converge::(&app_context.db, &app_context.config.database).await?; - if let Some(pool) = &app_context.redis { - redis::converge(pool, &app_context.config.redis).await?; + if let Some(pool) = &app_context.queue { + redis::converge(pool, &app_context.config.queue).await?; } run_app::(&mode, app_context).await @@ -305,9 +303,9 @@ fn create_processor(app_context: &AppContext) -> Result { queues = ?queues, "registering queues (merged config and default)" ); - let mut p = if let Some(redis) = &app_context.redis { + let mut p = if let Some(queue) = &app_context.queue { Processor::new( - redis.clone(), + queue.clone(), DEFAULT_QUEUES .iter() .map(ToString::to_string) @@ -315,7 +313,7 @@ fn create_processor(app_context: &AppContext) -> Result { ) } else { return Err(Error::Message( - "redis is missing, cannot initialize workers".to_string(), + "queue is missing, cannot initialize workers".to_string(), )); }; @@ -351,7 +349,7 @@ fn create_mailer(config: &config::Mailer) -> Result> { // TODO: Refactor to eliminate unwrapping and instead return an appropriate // error type. pub async fn connect_redis(config: &Config) -> Option> { - if let Some(redis) = &config.redis { + if let Some(redis) = &config.queue { let manager = RedisConnectionManager::new(redis.uri.clone()).unwrap(); let redis = Pool::builder().build(manager).await.unwrap(); Some(redis) diff --git a/src/config.rs b/src/config.rs index d1b00bd0c..1fbe49ddf 100644 --- a/src/config.rs +++ b/src/config.rs @@ -51,7 +51,7 @@ pub struct Config { pub server: Server, #[cfg(feature = "with-db")] pub database: Database, - pub redis: Option, + pub queue: Option, pub auth: Option, #[serde(default)] pub workers: Workers, diff --git a/src/controller/health.rs b/src/controller/health.rs index 9509cf66a..3829a3d4c 100644 --- a/src/controller/health.rs +++ b/src/controller/health.rs @@ -24,7 +24,7 @@ async fn health(State(ctx): State) -> Result { false } }; - if let Some(pool) = ctx.redis { + if let Some(pool) = ctx.queue { if let Err(error) = redis::ping(&pool).await { tracing::error!(err.msg = %error, err.detail = ?error, "health_redis_ping_error"); is_ok = false; diff --git a/src/worker.rs b/src/worker.rs index f42eaace0..4ca2e6ccb 100644 --- a/src/worker.rs +++ b/src/worker.rs @@ -35,12 +35,12 @@ where async fn perform_later(ctx: &AppContext, args: T) -> Result<()> { match &ctx.config.workers.mode { WorkerMode::BackgroundQueue => { - if let Some(redis) = &ctx.redis { - Self::perform_async(redis, args).await.unwrap(); + if let Some(queue) = &ctx.queue { + Self::perform_async(queue, args).await.unwrap(); } else { error!( error.msg = - "worker mode requested but no redis connection supplied, skipping job", + "worker mode requested but no queue connection supplied, skipping job", "worker_error" ); }