Function spf_milter::run

source ·
pub async fn run(
    listener: impl IntoListener,
    config: Config,
    reload: Receiver<()>,
    shutdown: impl Future
) -> Result<()>
Expand description

Starts SPF Milter listening on the given socket using the supplied configuration.

Calling this function installs a global logger as a side effect. Therefore, this function must not be called more than once.

Errors

If execution of the milter fails, an error is returned.

Examples

use spf_milter::Config;
use std::process;
use tokio::{net::TcpListener, signal, sync::mpsc};

let listener = TcpListener::bind("127.0.0.1:3000").await?;
let opts = Default::default();
let config = Config::read(opts).await?;
let (_, reload) = mpsc::channel(1);
let shutdown = signal::ctrl_c();

if let Err(e) = spf_milter::run(listener, config, reload, shutdown).await {
    eprintln!("failed to run spf-milter: {e}");
    process::exit(1);
}