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
Commit cursors immediately
Commit cursors as late as possible.
This strategy is determined by the commit timeout defined
via StreamParameters
Commit after on of the criteria was met:
seconds
: Afterseconds
seconds. If not set, it will be 10 seconds.cursors
: Aftercursors
cursors have been receivedevents
: Afterevents
have been received. This requires theBatchHandler
to give a hint on the amount of events processed.
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
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
impl RefUnwindSafe for CommitStrategy
impl Send for CommitStrategy
impl Sync for CommitStrategy
impl Unpin for CommitStrategy
impl UnwindSafe for CommitStrategy
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.
pub fn vzip(self) -> V
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