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

#[non_exhaustive]pub enum StreamDeadPolicy {
    Never,
    NoFramesFor {
        seconds: u32,
    },
    NoEventsFor {
        seconds: u32,
    },
}

Specifies when a stream is considered dead and has to be aborted.

Once a stream is considered dead a reconnect for a new stream will be attempted.

The default is NoFramesFor { seconds: 300 }

FromStr

use nakadion::consumer::StreamDeadPolicy;

let policy = "never".parse::<StreamDeadPolicy>().unwrap();
assert_eq!(policy, StreamDeadPolicy::Never);

let policy = "no_frames_for_seconds 1".parse::<StreamDeadPolicy>().unwrap();
assert_eq!(
    policy,
    StreamDeadPolicy::NoFramesFor { seconds: 1}
);

let policy = "no_events_for_seconds 2".parse::<StreamDeadPolicy>().unwrap();
assert_eq!(
    policy,
    StreamDeadPolicy::NoEventsFor { seconds: 2}
);

JSON is also valid:

use nakadion::consumer::StreamDeadPolicy;

let policy = r#""never""#.parse::<StreamDeadPolicy>().unwrap();
assert_eq!(policy, StreamDeadPolicy::Never);

let policy = r#"{"no_frames_for":{"seconds": 1}}"#.parse::<StreamDeadPolicy>().unwrap();
assert_eq!(
    policy,
    StreamDeadPolicy::NoFramesFor { seconds: 1}
);

let policy = r#"{"no_events_for":{"seconds": 2}}"#.parse::<StreamDeadPolicy>().unwrap();
assert_eq!(
    policy,
    StreamDeadPolicy::NoEventsFor { seconds: 2}
);

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.
Never

The stream is never considered dead

NoFramesFor

The stream is considered dead if no frames (lines) have been received from Nakadi for seconds

Fields of NoFramesFor

seconds: u32
NoEventsFor

The stream is considered dead if no events (lines with events) have been received from Nakadi for seconds

Fields of NoEventsFor

seconds: u32

Implementations

impl StreamDeadPolicy[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 " STREAM_DEAD_POLICY "

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

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

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

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

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

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

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

Trait Implementations

impl Clone for StreamDeadPolicy[src]

impl Copy for StreamDeadPolicy[src]

impl Debug for StreamDeadPolicy[src]

impl Default for StreamDeadPolicy[src]

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

impl Display for StreamDeadPolicy[src]

impl Eq for StreamDeadPolicy[src]

impl FromStr for StreamDeadPolicy[src]

type Err = Error

The associated error which can be returned from parsing.

impl PartialEq<StreamDeadPolicy> for StreamDeadPolicy[src]

impl Serialize for StreamDeadPolicy[src]

impl StructuralEq for StreamDeadPolicy[src]

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