[−][src]Enum nakadion::consumer::DispatchStrategy
Defines how to dispatch batches to handlers.
FromStr
use nakadion::consumer::DispatchStrategy; let strategy = "all_seq".parse::<DispatchStrategy>().unwrap(); assert_eq!(strategy, DispatchStrategy::AllSeq); let strategy = "event_type_par".parse::<DispatchStrategy>().unwrap(); assert_eq!(strategy, DispatchStrategy::EventTypePar); let strategy = "event_type_partition_par".parse::<DispatchStrategy>().unwrap(); assert_eq!(strategy, DispatchStrategy::EventTypePartitionPar);
JSON is also valid:
use nakadion::consumer::DispatchStrategy; let strategy = "{\"strategy\": \"all_seq\"}".parse::<DispatchStrategy>().unwrap(); assert_eq!(strategy, DispatchStrategy::AllSeq); let strategy = "{\"strategy\": \"event_type_par\"}".parse::<DispatchStrategy>().unwrap(); assert_eq!(strategy, DispatchStrategy::EventTypePar); let strategy = "{\"strategy\": \"event_type_partition_par\"}".parse::<DispatchStrategy>().unwrap(); assert_eq!(strategy, DispatchStrategy::EventTypePartitionPar);
Environment variables
Fetching values from the environment uses FromStr
for parsing.
Variants (Non-exhaustive)
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.
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 DispatchStrategy
.
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
.
Methods
impl DispatchStrategy
[src]
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_STRATEGY "
pub fn try_from_env_prefixed<T: Into<String>>(
prefix: T
) -> Result<Option<Self>, Error>
[src]
prefix: T
) -> Result<Option<Self>, Error>
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_STRATEGY
"
pub fn try_from_env_named<T: AsRef<str>>(
var_name: T
) -> Result<Option<Self>, Error>
[src]
var_name: T
) -> Result<Option<Self>, Error>
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 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_STRATEGY "
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_STRATEGY
"
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_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_STRATEGY "
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_STRATEGY
"
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
.
Trait Implementations
impl Clone for DispatchStrategy
[src]
fn clone(&self) -> DispatchStrategy
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for DispatchStrategy
[src]
impl Default for DispatchStrategy
[src]
impl<'de> Deserialize<'de> for DispatchStrategy
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Display for DispatchStrategy
[src]
impl Eq for DispatchStrategy
[src]
impl FromStr for DispatchStrategy
[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>
[src]
impl PartialEq<DispatchStrategy> for DispatchStrategy
[src]
fn eq(&self, other: &DispatchStrategy) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl Serialize for DispatchStrategy
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralEq for DispatchStrategy
[src]
impl StructuralPartialEq for DispatchStrategy
[src]
Auto Trait Implementations
impl RefUnwindSafe for DispatchStrategy
impl Send for DispatchStrategy
impl Sync for DispatchStrategy
impl Unpin for DispatchStrategy
impl UnwindSafe for DispatchStrategy
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> SendSyncUnwindSafe for T where
T: Send + Sync + UnwindSafe + ?Sized,
T: Send + Sync + UnwindSafe + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,