Struct faktory::ConsumerBuilder [−][src]
pub struct ConsumerBuilder<E> { /* fields omitted */ }
Convenience wrapper for building a Faktory worker.
See the Consumer
documentation for details.
Implementations
impl<E> ConsumerBuilder<E>
[src]
impl<E> ConsumerBuilder<E>
[src]pub fn hostname(&mut self, hn: String) -> &mut Self
[src]
Set the hostname to use for this worker.
Defaults to the machine’s hostname as reported by the operating system.
pub fn wid(&mut self, wid: String) -> &mut Self
[src]
Set a unique identifier for this worker.
Defaults to a randomly generated ASCII string.
pub fn labels(&mut self, labels: Vec<String>) -> &mut Self
[src]
Set the labels to use for this worker.
Defaults to ["rust"]
.
pub fn workers(&mut self, w: usize) -> &mut Self
[src]
Set the number of workers to use for run
and run_to_completion_*
.
Defaults to 1.
pub fn register<K, H>(&mut self, kind: K, handler: H) -> &mut Self where
K: Into<String>,
H: Fn(Job) -> Result<(), E> + Send + Sync + 'static,
[src]
K: Into<String>,
H: Fn(Job) -> Result<(), E> + Send + Sync + 'static,
Register a handler function for the given job type (kind
).
Whenever a job whose type matches kind
is fetched from the Faktory, the given handler
function is called with that job as its argument.
pub fn connect(self, url: Option<&str>) -> Result<Consumer<TcpStream, E>, Error>
[src]
Connect to a Faktory server.
If url
is not given, will use the standard Faktory environment variables. Specifically,
FAKTORY_PROVIDER
is read to get the name of the environment variable to get the address
from (defaults to FAKTORY_URL
), and then that environment variable is read to get the
server address. If the latter environment variable is not defined, the connection will be
made to
tcp://localhost:7419
If url
is given, but does not specify a port, it defaults to 7419.
pub fn connect_with<S: Read + Write>(
self,
stream: S,
pwd: Option<String>
) -> Result<Consumer<S, E>, Error>
[src]
self,
stream: S,
pwd: Option<String>
) -> Result<Consumer<S, E>, Error>
Connect to a Faktory server with a non-standard stream.
Trait Implementations
impl<E> Default for ConsumerBuilder<E>
[src]
impl<E> Default for ConsumerBuilder<E>
[src]Auto Trait Implementations
impl<E> !RefUnwindSafe for ConsumerBuilder<E>
impl<E> !RefUnwindSafe for ConsumerBuilder<E>
impl<E> Send for ConsumerBuilder<E>
impl<E> Send for ConsumerBuilder<E>
impl<E> Sync for ConsumerBuilder<E>
impl<E> Sync for ConsumerBuilder<E>
impl<E> Unpin for ConsumerBuilder<E>
impl<E> Unpin for ConsumerBuilder<E>
impl<E> !UnwindSafe for ConsumerBuilder<E>
impl<E> !UnwindSafe for ConsumerBuilder<E>