Enum nakadion::components::committer::CommitStrategy[][src]

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

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. If not set, it will be 10 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

The default name of the environment variable for this type. The name of the environment variable is “ COMMIT_STRATEGY “

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 “

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.

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.

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 “

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 “

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.

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.

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 “

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 “

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.

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.

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 “

Returns the seconds after which to always commit.

If CommitStrategy::Immediately is activated, Some(0) will be returned. If CommitStrategy::After is activated with seconds = None, Some(10) will be returned. If CommitStrategy::LatestPossible is activated, None will be returned.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Deserialize this value from the given Serde deserializer. Read more

Formats the value using the given formatter. Read more

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more