Skip to content

Commit

Permalink
Fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
amaury1093 committed Nov 25, 2024
1 parent 228d820 commit 3bb5052
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 36 deletions.
3 changes: 3 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ USER chrome

ENV RUST_LOG=reacher=info
ENV RCH__HTTP_HOST=0.0.0.0
# Currently this Dockerfile is mainly used for single-shot verifications, so we
# disable the worker by default.
ENV RCH__WORKER__ENABLED=false

EXPOSE 8080

Expand Down
37 changes: 16 additions & 21 deletions backend/backend_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,9 @@ hotmailb2c = "headless"
yahoo = "headless"

[worker]
enable = false

# Fields below are only used if the worker is enabled.

# Throttle the maximum number of requests per second, per minute, per hour, and
# per day for this worker.
# All fields are optional; comment them out to disable the limit.
#
# Important: these throttle configurations only apply to bulk verification and
# not to the single /v0/check_email endpoint. The latter endpoint always
# executes the verification immediately, regardless of the throttle settings.
[worker.throttle]
# max_requests_per_second = 20
# max_requests_per_minute = 100
# max_requests_per_hour = 1000
# max_requests_per_day = 20000
# Enable the worker to consume emails from the RabbitMQ queues. If set, the
# RabbitMQ configuration below must be set as well.
enable = true

# RabbitMQ configuration.
[worker.rabbitmq]
Expand All @@ -97,17 +84,25 @@ queues = "all"
# Number of concurrent emails to verify for this worker across all queues.
concurrency = 20

# Throttle the maximum number of requests per second, per minute, per hour, and
# per day for this worker.
# All fields are optional; comment them out to disable the limit.
#
# Important: these throttle configurations only apply to /v1/* endpoints, and
# not to the previous /v0/check_email endpoint. The latter endpoint always
# executes the verification immediately, regardless of the throttle settings.
[worker.throttle]
# max_requests_per_second = 20
# max_requests_per_minute = 100
# max_requests_per_hour = 1000
# max_requests_per_day = 20000

# Postgres configuration. Currently, a Postgres database is required to store
# the results of the verifications. This might change in the future, allowing
# for pluggable storage.
[worker.postgres]
db_url = "postgresql://localhost/reacherdb"

# Optional webhook URL to send the results to. This will send one POST request
# per email verification, with the result in the body.
# [worker.webhook.on_each_email]
# url = "http://localhost:8080/webhook"

# Optional Sentry configuration. If set, all errors will be sent to Sentry.
# [sentry]
# dsn = "<PASTE_YOUR_DSN_NOW>"
Expand Down
18 changes: 9 additions & 9 deletions backend/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ use config::Config;
#[cfg(feature = "worker")]
use lapin::Channel;
use serde::de::{self, Deserializer, Visitor};
use serde::Deserialize;
use serde::{Deserialize, Serialize};
use sqlx::PgPool;
#[cfg(feature = "worker")]
use std::sync::Arc;
use std::{env, fmt};

#[derive(Debug, Default, Deserialize)]
#[derive(Debug, Default, Serialize, Deserialize)]
pub struct BackendConfig {
/// Name of the backend.
pub backend_name: String,
Expand Down Expand Up @@ -135,7 +135,7 @@ impl BackendConfig {
}
}

#[derive(Debug, Default, Deserialize, Clone)]
#[derive(Debug, Default, Deserialize, Clone, Serialize)]
pub struct VerifMethodConfig {
/// Verification method for Gmail emails.
pub gmail: GmailVerifMethod,
Expand All @@ -147,7 +147,7 @@ pub struct VerifMethodConfig {
pub yahoo: YahooVerifMethod,
}

#[derive(Debug, Default, Deserialize, Clone)]
#[derive(Debug, Default, Deserialize, Clone, Serialize)]
pub struct WorkerConfig {
pub enable: bool,

Expand Down Expand Up @@ -179,7 +179,7 @@ pub struct MustWorkerConfig {
pub postgres: PostgresConfig,
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize)]
pub enum RabbitMQQueues {
All,
Only(Vec<Queue>),
Expand Down Expand Up @@ -244,7 +244,7 @@ impl RabbitMQQueues {
}
}

#[derive(Debug, Deserialize, Clone)]
#[derive(Debug, Deserialize, Clone, Serialize)]
pub struct RabbitMQConfig {
pub url: String,
/// Queues to consume emails from. By default the worker consumes from all
Expand All @@ -271,7 +271,7 @@ pub struct RabbitMQConfig {
/// Queue names that the worker can consume from. Each email is routed to a
/// one and only one queue, based on the email provider. A single worker can
/// consume from multiple queues.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize)]
pub enum Queue {
Gmail,
HotmailB2B,
Expand Down Expand Up @@ -335,12 +335,12 @@ impl<'de> Deserialize<'de> for Queue {
}
}

#[derive(Debug, Deserialize, Clone)]
#[derive(Debug, Deserialize, Clone, Serialize)]
pub struct PostgresConfig {
pub db_url: String,
}

#[derive(Debug, Deserialize, Clone)]
#[derive(Debug, Deserialize, Clone, Serialize)]
pub struct ThrottleConfig {
pub max_requests_per_second: Option<u32>,
pub max_requests_per_minute: Option<u32>,
Expand Down
8 changes: 4 additions & 4 deletions backend/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
//! functions, depending on whether the `bulk` feature is enabled or not.
use check_if_email_exists::{setup_sentry, LOG_TARGET};
use reacher_backend::config::load_config;
use reacher_backend::http::run_warp_server;
#[cfg(feature = "worker")]
use reacher_backend::worker::run_worker;
use std::sync::Arc;
use tracing::info;

use reacher_backend::config::load_config;
use reacher_backend::http::run_warp_server;
use tracing::{debug, info};

const CARGO_PKG_VERSION: &str = env!("CARGO_PKG_VERSION");

Expand All @@ -35,6 +34,7 @@ async fn main() -> Result<(), anyhow::Error> {
tracing_subscriber::fmt::init();
info!(target: LOG_TARGET, version=?CARGO_PKG_VERSION, "Running Reacher");
let config = load_config().await?;
debug!(target: LOG_TARGET, "{:#?}", config);

// Setup sentry bug tracking.
let _guard: sentry::ClientInitGuard;
Expand Down
2 changes: 2 additions & 0 deletions core/src/smtp/outlook/microsoft365.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ impl From<ReqwestError> for Microsoft365Error {
}

/// Convert an email address to its corresponding OneDrive URL.
#[allow(dead_code)]
fn get_onedrive_url(email_address: &str) -> String {
let (username, domain) = email_address
.split_once('@')
Expand All @@ -64,6 +65,7 @@ fn get_onedrive_url(email_address: &str) -> String {
/// a reliable indicator that an email-address is valid. However, a negative
/// response is ambigious: the email address may or may not be valid but this
/// cannot be determined by the method outlined here.
#[allow(dead_code)]
pub async fn check_microsoft365_api(
to_email: &EmailAddress,
input: &CheckEmailInput,
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ services:
restart: always

worker1:
image: reacherhq/backend:v0.10.0-beta.0
image: reacherhq/backend:v0.10.0-beta.2
container_name: worker1
ports:
- "8080:8080"
Expand All @@ -41,7 +41,7 @@ services:
restart: always

worker2:
image: reacherhq/backend:v0.10.0-beta.0
image: reacherhq/backend:v0.10.0-beta.2
container_name: worker2
ports:
- "8081:8080"
Expand Down

0 comments on commit 3bb5052

Please sign in to comment.