Struct netidx::subscriber::Dval[][src]

pub struct Dval(_);

Dval is a durable value subscription. it behaves just like Val, except that if it dies a task within subscriber will attempt to resubscribe. The resubscription process goes through the entire resolution and connection process again, so Dval is robust to many failures. For example,

  • multiple publishers are publishing on a path and one of them dies. Dval will transparently move to another one.

  • a publisher is restarted (possibly on a different machine). Dval will wait using linear backoff for the publisher to come back, and then it will resubscribe.

  • The resolver server cluster is restarted. In this case existing subscriptions won’t die, but new ones will fail while the cluster is down. However once it is back up, and the publishers have republished all their data, which they will do automatically, Dval will resubscribe to anything it couldn’t find while the resolver server cluster was down.

A Dval uses a bit more memory than a Val subscription, but other than that the performance is the same. It is therefore recommended that you use Dval as the default kind of value subscription. If stop_collecting_last is true then the subscriber will stop storing the last value in addition to giving it to this channel. The last method will return null from now on, and the passed in channel will be the only way of getting data from the subscription. This improves performance at the expense of flexibility.

If all user held references to Dval are dropped it will be unsubscribed.

Implementations

impl Dval[src]

pub fn downgrade(&self) -> DvalWeak[src]

pub fn last(&self) -> Event[src]

Get the last value published by the publisher, or Unsubscribed if the subscription is currently dead.

pub fn updates(
    &self,
    flags: UpdatesFlags,
    tx: Sender<Pooled<Vec<(SubId, Event)>>>
)
[src]

Register tx to receive updates to this Dval.

You may register multiple different channels to receive updates from a Dval, and you may register one channel to receive updates from multiple Dvals.

pub async fn wait_subscribed(&self) -> Result<()>[src]

Wait until the Dval is subscribed and then return. This is not a guarantee that the Dval will stay subscribed for any length of time, just that at the moment this method returns the Dval is subscribed. If the Dval is subscribed when this method is called, it will return immediatly without allocating any resources.

pub fn write(&self, v: Value) -> bool[src]

Write a value back to the publisher, see Val::write. If we aren’t currently subscribed the write will be queued and sent when we are. The return value will be true if the write was sent immediatly, and false if it was queued. It is still possible that a write will be dropped e.g. if the connection dies while we are writing it.

pub fn write_with_recipt(&self, v: Value) -> Receiver<Value>[src]

This does the same thing as write except that it requires the publisher send a reply indicating the outcome of the request. The reply can be read from the returned oneshot channel.

Note that compared to write this function has higher overhead, avoid it in situations where high message volumes are required.

If we are not currently subscribed then the write will be queued until we are. It is still possible that a write will be dropped e.g. if the connection dies while we are writing it.

pub fn clear_queued_writes(&self)[src]

Clear the write queue

pub fn queued_writes(&self) -> usize[src]

Return the number of queued writes

pub fn id(&self) -> SubId[src]

return the unique id of this Dval

Trait Implementations

impl Clone for Dval[src]

impl Debug for Dval[src]

Auto Trait Implementations

impl !RefUnwindSafe for Dval

impl Send for Dval

impl Sync for Dval

impl Unpin for Dval

impl !UnwindSafe for Dval

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> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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>,