[][src]Enum nakadion::consumer::complex_types::DispatchMode

#[non_exhaustive]pub enum DispatchMode {
    AllSeq,
    EventTypePar,
    EventTypePartitionPar,
}

Defines how to dispatch batches to handlers.

The default is DispatchMode::AllSeq

FromStr

use nakadion::consumer::DispatchMode;

let strategy = "all_seq".parse::<DispatchMode>().unwrap();
assert_eq!(strategy, DispatchMode::AllSeq);

let strategy = "event_type_par".parse::<DispatchMode>().unwrap();
assert_eq!(strategy, DispatchMode::EventTypePar);

let strategy = "event_type_partition_par".parse::<DispatchMode>().unwrap();
assert_eq!(strategy, DispatchMode::EventTypePartitionPar);

JSON is also valid:

use nakadion::consumer::DispatchMode;

let strategy = "\"all_seq\"".parse::<DispatchMode>().unwrap();
assert_eq!(strategy, DispatchMode::AllSeq);

let strategy = "\"event_type_par\"".parse::<DispatchMode>().unwrap();
assert_eq!(strategy, DispatchMode::EventTypePar);

let strategy = "\"event_type_partition_par\"".parse::<DispatchMode>().unwrap();
assert_eq!(strategy, DispatchMode::EventTypePartitionPar);

Environment variables

Fetching values from the environment uses FromStr for parsing.

Variants (Non-exhaustive)

Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
AllSeq

Dispatch all batches to a single worker(handler)

This means batches all are processed sequentially by a single handler.

This will always request a handler with HandlerAssignment::Unspecified from the BatchHandlerFactory. This means that if multiple event types are consumed, the handler is responsible for determining the event type to be processed from BatchMeta.

It is suggested to not use this strategy if multiple event types are expected.

EventTypePar

Dispatch all batches to a dedicated worker for an event type.

This means batches are processed sequentially for each event type but the maximum parallelism is the number of event types.

This will always request a handler with HandlerAssignment::EventType(EventTypeName) from the BatchHandlerFactory.

This is the default DispatchMode.

EventTypePartitionPar

Dispatch all batches to a dedicated worker for an partition on each event type.

This means batches are processed sequentially for each individual partition of an event type. The maximum parallelism is the sum of each event type multiplied by its number of partitions.

This will always request a handler with HandlerAssignment::EventTypePartition(EventTypePartitionName) from the BatchHandlerFactory.

Implementations

impl DispatchMode[src]

pub const ENV_TYPE_NAME: &'static str[src]

The default name of the environment variable for this type. The name of the environment variable is " DISPATCH_MODE "

pub fn try_from_env() -> Result<Option<Self>, Error>[src]

Initialize from the environment. Returns None if the value was not found and fails if the value could not be parsed. The name of the environment variable is "NAKADION_ DISPATCH_MODE "

pub fn try_from_env_prefixed<T: Into<String>>(
    prefix: T
) -> Result<Option<Self>, Error>
[src]

Initialize from the environment. Returns None if the value was not found and fails if the value could not be parsed. The name of the environment variable is "prefix_ DISPATCH_MODE " The underscore and prefix will be omitted if prefix is empty.

pub fn try_from_env_named<T: AsRef<str>>(
    var_name: T
) -> Result<Option<Self>, Error>
[src]

Initialize from the environment. Returns None if the value was not found and fails if the value could not be parsed. The name of the environment variable is var_name.

pub fn try_from_env_type_name() -> Result<Option<Self>, Error>[src]

Initialize from the environment. Returns None if the value was not found and fails if the value could not be parsed. The name of the environment variable is " DISPATCH_MODE "

pub fn from_env() -> Result<Self, Error>[src]

Initialize from the environment. Fails if the value was not found or if the value could not be parsed. The name of the environment variable is "NAKADION_ DISPATCH_MODE "

pub fn from_env_prefixed<T: Into<String>>(prefix: T) -> Result<Self, Error>[src]

Initialize from the environment. Fails if the value was not found or if the value could not be parsed. The name of the environment variable is "prefix_ DISPATCH_MODE " The underscore and prefix will be omitted if prefix is empty.

pub fn from_env_named<T: AsRef<str>>(var_name: T) -> Result<Self, Error>[src]

Initialize from the environment. Fails if the value was not found or if the value could not be parsed. The name of the environment variable is var_name.

pub fn from_env_type_name() -> Result<Self, Error>[src]

Initialize from the environment. Fails if the value was not found or if the value could not be parsed. The name of the environment variable is " DISPATCH_MODE "

pub fn from_env_opt() -> Option<Self>[src]

Initialize from the environment. Returns None if the value could not be read for any reason. The name of the environment variable is "NAKADION_ DISPATCH_MODE "

pub fn from_env_opt_prefixed<T: Into<String>>(prefix: T) -> Option<Self>[src]

Initialize from the environment. Returns None if the value could not be read for any reason. The name of the environment variable is "prefix_ DISPATCH_MODE " The underscore and prefix will be omitted if prefix is empty.

pub fn from_env_opt_named<T: AsRef<str>>(var_name: T) -> Option<Self>[src]

Initialize from the environment. Returns None if the value could not be read for any reason. The name of the environment variable is var_name.

pub fn from_env_opt_type_name() -> Option<Self>[src]

Initialize from the environment. Returns None if the value could not be read for any reason. The name of the environment variable is " DISPATCH_MODE "

Trait Implementations

impl Clone for DispatchMode[src]

impl Copy for DispatchMode[src]

impl Debug for DispatchMode[src]

impl Default for DispatchMode[src]

impl<'de> Deserialize<'de> for DispatchMode[src]

impl Display for DispatchMode[src]

impl Eq for DispatchMode[src]

impl FromStr for DispatchMode[src]

type Err = Error

The associated error which can be returned from parsing.

impl PartialEq<DispatchMode> for DispatchMode[src]

impl Serialize for DispatchMode[src]

impl StructuralEq for DispatchMode[src]

impl StructuralPartialEq for DispatchMode[src]

Auto Trait Implementations

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> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

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

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

impl<T> SendSyncUnwindSafe for T where
    T: Send + Sync + UnwindSafe + ?Sized

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

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>,