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]

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]

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]

Connect to a Faktory server with a non-standard stream.

Trait Implementations

impl<E> Default for ConsumerBuilder<E>[src]

fn default() -> Self[src]

Construct a new worker with default worker options and the url fetched from environment variables.

This will construct a worker where:

  • hostname is this machine’s hostname.
  • wid is a randomly generated string.
  • pid is the OS PID of this process.
  • labels is ["rust"].

Auto Trait Implementations

impl<E> !RefUnwindSafe for ConsumerBuilder<E>

impl<E> Send for ConsumerBuilder<E>

impl<E> Sync for ConsumerBuilder<E>

impl<E> Unpin for ConsumerBuilder<E>

impl<E> !UnwindSafe for ConsumerBuilder<E>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,