Trait HostSubscribe

Source
pub trait HostSubscribe {
    type HostError: Into<Error>;
    type HostStream: Stream<Item = IpList, Error = Self::HostError>;

    // Required method
    fn subscribe_host(&self, name: &Name) -> Self::HostStream;
}
Expand description

A resolver that allows to subscribe on the host name and receive updates

Required Associated Types§

Source

type HostError: Into<Error>

An error type returned by a stream

This is usually either abstract_ns::Error or Void, showing whether error can actually occur, but can be any other error at your convenience.

Note: this is an associated type so that connection pool implementations could accept SubscribeHost<Error=Void> as there are no reason to shutdown pool if there is a temporary error in name resolution (and all errors should be considered temporary as user can even fix invalid name by fixing configuration file while connection pool is operating).

Source

type HostStream: Stream<Item = IpList, Error = Self::HostError>

A stream returned from subscribe()

Required Methods§

Source

fn subscribe_host(&self, name: &Name) -> Self::HostStream

Resolve a name and subscribe to the updates

Note: errors returned by a stream are considered fatal but temporary. I.e. stream can’t be used after an error, but user might subscribe again after a short interval.

For efficiency it might be useful to attempt name resolution few times if the error is temporary before returning an error, but on network resolver fatal errors (or subsequent temporary ones) should be returned so middleware and routers can failover to other sources and put errors to log.

Implementations on Foreign Types§

Source§

impl<T: HostSubscribe> HostSubscribe for Arc<T>

Implementors§