Struct slog_retry::Retry [] [src]

pub struct Retry<Slave, Factory> { /* fields omitted */ }

The retry adapter.

This wraps another drain and forwards log records into that. However, if the drain returns an error, it discards it and tries to create a new one and log the message into it.

It uses the retry strategy to decide how long to wait before retrying and how many times. If the retry strategy runs out of items, it gives up, returns an error and the log record is lost.

However, it is not destroyed by the error and if it is called to log another record, it tries to reconnect again (using a fresh instance of the strategy).

Warning

This adapter is synchronous and blocks during the retry attempts. Unless you provide a retry strategy with a single zero item, you don't want to use it directly. Wrap it inside slog-async, where it'll only slow down the logging thread and the channel into that thread will be used as a buffer for messages waiting to be written after the reconnect.

Methods

impl<Slave, FactoryError, Factory> Retry<Slave, Factory> where
    Slave: Drain,
    FactoryError: Fail + Debug,
    Slave::Err: Fail + Debug,
    Factory: Fn() -> Result<Slave, FactoryError>, 
[src]

[src]

Creates a new retry adapter.

Parameters

  • factory: A factory function that is used to produce new instance of the slave drain on every (re)connection attempt.
  • strategy: A reconnect strategy, describing how long to wait between attempts and how many attempts to make. If set to None a default strategy with 4 increasingly delayed attemps is used.
  • connect_now: Should a connection be made right away. If it is set to true, it may block (it uses the reconnect strategy provided) and it may return an error. If set to false, the connection is made on the first logged message. No matter if connecting now or later, the first connection attempt is without waiting.

Trait Implementations

impl<Slave, FactoryError, Factory> Drain for Retry<Slave, Factory> where
    Slave: Drain,
    FactoryError: Fail + Debug,
    Slave::Err: Fail + Debug,
    Factory: Fn() -> Result<Slave, FactoryError>, 
[src]

Type returned by this drain Read more

Type of potential errors that can be returned by this Drain

[src]

Handle one logging statement (Record) Read more

[src]

Avoid: Check if messages at the specified log level are maybe enabled for this logger. Read more

[src]

Avoid: See is_enabled

[src]

Avoid: See is_enabled

[src]

Avoid: See is_enabled

[src]

Avoid: See is_enabled

[src]

Avoid: See is_enabled

[src]

Avoid: See is_enabled

[src]

Pass Drain through a closure, eg. to wrap into another Drain. Read more

[src]

Filter logging records passed to Drain Read more

[src]

Filter logging records passed to Drain (by level) Read more

[src]

Map logging errors returned by this drain Read more

[src]

Ignore results returned by this drain Read more

[src]

Make Self panic when returning any errors Read more

Auto Trait Implementations

impl<Slave, Factory> Send for Retry<Slave, Factory> where
    Factory: Send,
    Slave: Send

impl<Slave, Factory> !Sync for Retry<Slave, Factory>