Struct ns_env_config::Router [] [src]

pub struct Router { /* fields omitted */ }

An actual router class

Note: when router is shut down (when config stream is closed), all futures and subscriptions are canceled.

Since 0.1.3: when all instances of Router are dropped the underlying futures and streams continue to work, until all of them finish (for subscriptions it means subscriber is dropped). In previous versions this dropped all requests immediately. This was common source of confusion and we consider this a bug. If you want to force close all futures and subscriptions create a router with from_stream or updating_config and send EOS on stream or drop UpdatingSink respectively.

Methods

impl Router
[src]

[src]

Create a router for a static config

[src]

Create a router with updating config

Note: router is defunctional until first config is received in a stream. By defunctional we mean that every request will wait, until configured.

Note 2: when stream is closed router is shut down, so usually the stream must be infinite.

[src]

Create a router and update channel

Note: router is shut down when UpdateSink is dropped. So keep it somewhere so you can update config.

[src]

Subscribes to a list of names

This is intended to keep list of services in configuration file, like this (yaml):

addresses:
- example.org:8080
- _my._svc.example.org  # SVC record
- example.net           # default port

You can also specify a way to resolve the service by providing iterator over AutoName instances instead of plain &str (both are accepted in this method).

[src]

Deprecated since 0.1.1

: use subscribe_stream()

Subscribes to a stream that yields lists of names

See the description of subscribe_many for the description of the list of names that must be yielded from the stream.

Note: this is meant for configuration update scenario. I.e. when configuration is reloaded and new list of names is received, it should be pushed to this stream. The items received in the stream are non-cumulative and replace previous list.

Note 2: If stream is errored or end-of-stream reached, this means name is not needed any more and its AddrStream will be shut down, presumably shutting down everything that depends on it.

[src]

Subscribes to a stream that yields lists of names

See the description of subscribe_many for the description of the list of names that must be yielded from the stream.

Note: this is meant for configuration update scenario. I.e. when configuration is reloaded and new list of names is received, it should be pushed to this stream. The items received in the stream are non-cumulative and replace previous list.

Note 2: If stream is errored or end-of-stream reached, this means name is not needed any more and its AddrStream will be shut down, presumably shutting down everything that depends on it.

[src]

Resolve a string or other things into an address

See description of subscribe_many to find out how names are parsed

See [AutoName] for supported types

[AutoName]:

Trait Implementations

impl Clone for Router
[src]

[src]

impl Resolve for Router
[src]

[src]

impl HostSubscribe for Router
[src]

impl Debug for Router
[src]

[src]

Formats the value using the given formatter.

impl Subscribe for Router
[src]

[src]

impl HostResolve for Router
[src]

A future returned from resolve()

[src]

Resolve a name to an address once

[src]

Create a subscriber that resolves once using this resolver and never updates a stream Read more

[src]

Create a thing that implements Resolve+HostResolve but returns NameNotFound on resolve Read more