Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
amaury1093 committed Nov 30, 2024
1 parent 79854d6 commit 1f04ece
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 33 deletions.
13 changes: 2 additions & 11 deletions backend/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl BackendConfig {
postgres: postgres.clone(),
}),
#[cfg(feature = "worker")]
(true, _, _, _, _, _, _) => bail!("Worker configuration is missing"),
(true, _, _, _, _, _) => bail!("Worker configuration is missing"),
_ => bail!("Calling must_worker_config on a non-worker backend"),
}
}
Expand Down Expand Up @@ -232,19 +232,10 @@ impl ThrottleConfig {
/// Load the worker configuration from the worker_config.toml file and from the
/// environment.
pub async fn load_config() -> Result<BackendConfig, anyhow::Error> {
let mut cfg = Config::builder()
let cfg = Config::builder()
.add_source(config::File::with_name("backend_config"))
.add_source(config::Environment::with_prefix("RCH").separator("__"));

// The RCH__WORKER__RABBITMQ__QUEUES is always read as a str, whereas we
// sometimes want to parse it as a list of strings, if it's not "all". We
// handle this case separately.
if let Ok(queues) = env::var("RCH__WORKER__RABBITMQ__QUEUES") {
if queues != "all" {
let queues: Vec<String> = queues.split(',').map(String::from).collect();
cfg = cfg.set_override("worker.rabbitmq.queues", queues)?;
}
}
let cfg = cfg.build()?.try_deserialize::<BackendConfig>()?;

if !cfg.worker.enable && (cfg.worker.rabbitmq.is_some() || cfg.worker.throttle.is_some()) {
Expand Down
1 change: 0 additions & 1 deletion backend/src/http/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use check_if_email_exists::{CheckEmailInputBuilderError, LOG_TARGET};
use serde::ser::SerializeStruct;
use serde::Serialize;
use sqlx::any;
use std::fmt;
use std::fmt::Debug;
use tracing::error;
Expand Down
7 changes: 4 additions & 3 deletions backend/src/http/v1/bulk/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ async fn http_handler(
.map_err(ReacherResponseError::from)?;

let n = body.input.len();
let stream = futures::stream::iter(body.input);
let webhook = body.webhook.clone();
let stream = futures::stream::iter(body.input.into_iter());

let properties = BasicProperties::default()
.with_content_type("application/json".into())
Expand All @@ -95,7 +96,7 @@ async fn http_handler(
let task = CheckEmailTask {
input,
job_id: CheckEmailJobId::Bulk(rec.id),
webhook: body.webhook.clone(),
webhook: webhook.clone(),
};

publish_task(
Expand All @@ -113,7 +114,7 @@ async fn http_handler(
info!(
target: LOG_TARGET,
queue = CHECK_EMAIL_QUEUE,
"Added {n} emails to the queue",
"Added {n} emails",
);
Ok(warp::reply::json(&Response { job_id: rec.id }))
}
Expand Down
14 changes: 6 additions & 8 deletions docker-compose.local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,39 +27,37 @@ services:
- ./backend/postgres_data:/var/lib/postgresql/data
restart: always

worker_smtp:
worker1:
build:
context: .
dockerfile: backend/Dockerfile
container_name: worker_smtp
container_name: worker1
ports:
- "8080:8080"
depends_on:
- postgres
- rabbitmq
environment:
RCH__BACKEND_NAME: worker_smtp
RCH__BACKEND_NAME: worker1
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

worker_headless:
worker2:
build:
context: .
dockerfile: backend/Dockerfile
container_name: worker_headless
container_name: worker2
ports:
- "8081:8080"
depends_on:
- postgres
- rabbitmq
environment:
RCH__BACKEND_NAME: worker_headless
RCH__BACKEND_NAME: worker2
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
Expand Down
16 changes: 6 additions & 10 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,36 @@ services:
POSTGRES_DB: reacher_db
restart: always

worker_smtp:
worker1:
image: reacherhq/backend:beta
container_name: worker_smtp
container_name: worker1
ports:
- "8080:8080"
depends_on:
- postgres
- rabbitmq
environment:
RCH__BACKEND_NAME: worker_smtp
RCH__BACKEND_NAME: worker1
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 for SMTP requests
restart: always

worker_headless:
worker2:
image: reacherhq/backend:beta
container_name: worker_headless
container_name: worker2
ports:
- "8081:8080"
depends_on:
- postgres
- rabbitmq
environment:
RCH__BACKEND_NAME: worker_headless
RCH__BACKEND_NAME: worker2
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_MINUTE: 100 # Recommended limit for headless verifications
restart: always

0 comments on commit 1f04ece

Please sign in to comment.