[][src]Enum nakadion::consumer::CommitStrategy

pub enum CommitStrategy {
    Immediately,
    LatestPossible,
    After {
        seconds: Option<u32>,
        cursors: Option<u32>,
        events: Option<u32>,
    },
}

Defines how to commit cursors

This value should always be set when creating a Consumer because otherwise a it will be guessed by Nakadion which might not result in best performance.

FromStr

use nakadion::components::committer::CommitStrategy;

let strategy = "immediately".parse::<CommitStrategy>().unwrap();
assert_eq!(strategy, CommitStrategy::Immediately);

let strategy = "latest_possible".parse::<CommitStrategy>().unwrap();
assert_eq!(strategy, CommitStrategy::LatestPossible);

let strategy = "after seconds:1 cursors:2 events:3".parse::<CommitStrategy>().unwrap();
assert_eq!(
    strategy,
    CommitStrategy::After {
        seconds: Some(1),
        cursors: Some(2),
        events: Some(3),
    }
);

let strategy = "after seconds:1 events:3".parse::<CommitStrategy>().unwrap();
assert_eq!(
    strategy,
    CommitStrategy::After {
        seconds: Some(1),
        cursors: None,
        events: Some(3),
    }
);

assert!("after".parse::<CommitStrategy>().is_err());

JSON is also valid:

use nakadion::components::committer::CommitStrategy;

let strategy = r#""immediately""#.parse::<CommitStrategy>().unwrap();
assert_eq!(strategy, CommitStrategy::Immediately);

let strategy = r#""latest_possible""#.parse::<CommitStrategy>().unwrap();
assert_eq!(strategy, CommitStrategy::LatestPossible);

let strategy = r#"{"after":{"seconds":1, "cursors":3}}"#.parse::<CommitStrategy>().unwrap();
assert_eq!(
    strategy,
    CommitStrategy::After {
        seconds: Some(1),
        cursors: Some(3),
        events: None,
    }
);

Environment variables

Fetching values from the environment uses FromStr for parsing

Variants

Immediately

Commit cursors immediately

LatestPossible

Commit cursors as late as possible.

This strategy is determined by the commit timeout defined via StreamParameters

After

Commit after on of the criteria was met:

  • seconds: After seconds seconds
  • cursors: After cursors cursors have been received
  • events: After events have been received. This requires the BatchHandler to give a hint on the amount of events processed.

Fields of After

seconds: Option<u32>cursors: Option<u32>events: Option<u32>

Implementations

impl CommitStrategy[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 " COMMIT_STRATEGY "

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_ COMMIT_STRATEGY "

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_ COMMIT_STRATEGY " 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 " COMMIT_STRATEGY "

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_ COMMIT_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_ COMMIT_STRATEGY " 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 " COMMIT_STRATEGY "

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_ COMMIT_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_ COMMIT_STRATEGY " 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 " COMMIT_STRATEGY "

pub fn after_seconds(seconds: u32) -> Self[src]

pub fn validate(&self) -> Result<(), Error>[src]

pub fn derive_from_stream_parameters(
    stream_parameters: &StreamParameters
) -> Self
[src]

Trait Implementations

impl Clone for CommitStrategy[src]

impl Copy for CommitStrategy[src]

impl Debug for CommitStrategy[src]

impl Default for CommitStrategy[src]

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

impl Display for CommitStrategy[src]

impl Eq for CommitStrategy[src]

impl FromStr for CommitStrategy[src]

type Err = Error

The associated error which can be returned from parsing.

impl PartialEq<CommitStrategy> for CommitStrategy[src]

impl Serialize for CommitStrategy[src]

impl StructuralEq for CommitStrategy[src]

impl StructuralPartialEq for CommitStrategy[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>,