pub struct SpawnerConfig { /* private fields */ }
Expand description

SpawnerConfig is the only part of this library required to actually exist in your application.

This type is used to queue new jobs into the background-jobs server.

let spawner = SpawnerConfig::new("localhost", 5555);

tokio::spawn(
    spawner
        .queue::<MyProcessor>(job)
        .map_err(|_| ()),
);

Implementations

Create a SpawnerConfig

  • server_host is the hostname or IP address of the host that the server is running on
  • base_port is the same base_port from the server config. The spawner will only ever need to communicate over base_port

The same as SpawnerConfig::new(), but with a provided ZeroMQ Context.

This can be useful if you have other uses of ZeroMQ in your application, and want to share a context with your dependencies.

If you’re running the Server, Worker, and Spawner in the same application, you should share a ZeroMQ context between them.

Queue a job to be executed in the background

queue_sync is the same as Queue, except that it blocks the current thread while it is sending the message to the jobs server.

If you have a tokio-based application, you should use queue instead.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.