Skip to content

Commit

Permalink
fix: Support queues in env var
Browse files Browse the repository at this point in the history
  • Loading branch information
amaury1093 committed Nov 27, 2024
1 parent ce5067e commit 39655d5
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion backend/backend_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ url = "amqp://guest:guest@localhost:5672"
#
# Env variable: RCH__WORKER__RABBITMQ__QUEUES
#
# queues = ["check.gmail", "check.hotmail.b2b", "check.hotmail.b2c", "check.yahoo", "check.everything_else"]
# queues = ["check.gmail", "check.hotmailb2b", "check.hotmailb2c", "check.yahoo", "check.everything_else"]
queues = "all"

# Number of concurrent emails to verify for this worker across all queues.
Expand Down
7 changes: 6 additions & 1 deletion backend/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,12 @@ impl ThrottleConfig {
pub async fn load_config() -> Result<BackendConfig, anyhow::Error> {
let cfg = Config::builder()
.add_source(config::File::with_name("backend_config"))
.add_source(config::Environment::with_prefix("RCH").separator("__"))
.add_source(
config::Environment::with_prefix("RCH")
.separator("__")
.try_parsing(true)
.list_separator(","),
)
.build()?;

let mut cfg = cfg.try_deserialize::<BackendConfig>()?;
Expand Down
12 changes: 6 additions & 6 deletions docker-compose.local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,37 +27,37 @@ services:
- ./backend/postgres_data:/var/lib/postgresql/data
restart: always

worker1:
worker_smtp:
build:
context: .
dockerfile: backend/Dockerfile
container_name: worker1
container_name: worker_smtp
ports:
- "8080:8080"
depends_on:
- postgres
- rabbitmq
environment:
RCH__BACKEND_NAME: worker1
RCH__BACKEND_NAME: worker_smtp
RUST_LOG: reacher=info
RCH__HTTP_HOST: 0.0.0.0
RCH__WORKER__ENABLE: true
RCH__WORKER__RABBITMQ__URL: amqp://guest:guest@rabbitmq:5672
RCH__WORKER__POSTGRES__DB_URL: postgres://postgres:postgres@postgres:5432/reacher_db
restart: always

worker2:
worker_headless:
build:
context: .
dockerfile: backend/Dockerfile
container_name: worker2
container_name: worker_headless
ports:
- "8081:8080"
depends_on:
- postgres
- rabbitmq
environment:
RCH__BACKEND_NAME: worker2
RCH__BACKEND_NAME: worker_headless
RUST_LOG: reacher=info
RCH__HTTP_HOST: 0.0.0.0
RCH__WORKER__ENABLE: true
Expand Down
18 changes: 10 additions & 8 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,40 @@ services:
POSTGRES_DB: reacher_db
restart: always

worker1:
worker_smtp:
image: reacherhq/backend:beta
container_name: worker1
container_name: worker_smtp
ports:
- "8080:8080"
depends_on:
- postgres
- rabbitmq
environment:
RCH__BACKEND_NAME: worker1
RCH__BACKEND_NAME: worker_smtp
RUST_LOG: reacher=info
RCH__HTTP_HOST: 0.0.0.0
RCH__WORKER__ENABLE: true
RCH__WORKER__RABBITMQ__URL: amqp://guest:guest@rabbitmq:5672
RCH__WORKER__RABBITMQ__QUEUES: check.gmail,check.hotmailb2b,check.everything_else
RCH__WORKER__POSTGRES__DB_URL: postgres://postgres:postgres@postgres:5432/reacher_db
RCH__WORKER__THROTTLE__MAX_REQUESTS_PER_DAY: 10000 # Recommended limit per IP per day
RCH__WORKER__THROTTLE__MAX_REQUESTS_PER_DAY: 10000 # Recommended limit per IP per day for SMTP requests
restart: always

worker2:
worker_headless:
image: reacherhq/backend:beta
container_name: worker2
container_name: worker_headless
ports:
- "8081:8080"
depends_on:
- postgres
- rabbitmq
environment:
RCH__BACKEND_NAME: worker2
RCH__BACKEND_NAME: worker_headless
RUST_LOG: reacher=info
RCH__HTTP_HOST: 0.0.0.0
RCH__WORKER__ENABLE: true
RCH__WORKER__RABBITMQ__URL: amqp://guest:guest@rabbitmq:5672
RCH__WORKER__RABBITMQ__QUEUES: check.hotmailb2c,check.yahoo
RCH__WORKER__POSTGRES__DB_URL: postgres://postgres:postgres@postgres:5432/reacher_db
RCH__WORKER__THROTTLE__MAX_REQUESTS_PER_DAY: 10000 # Recommended limit per IP per day
RCH__WORKER__THROTTLE__MAX_REQUESTS_PER_MINUTE: 100 # Recommended limit for headless verifications
restart: always

0 comments on commit 39655d5

Please sign in to comment.