public static async Task Unsubscribe <TItem>(this StreamRef <TItem> stream, ActorGrain actor) { Requires.NotNull(actor, nameof(actor)); var subscriptions = await stream.Subscriptions(); if (subscriptions.Count == 0) { return; } Debug.Assert(subscriptions.Count == 1, "We should keep only one active subscription per-stream per-actor"); await subscriptions[0].Unsubscribe(); }
public static async Task Resume(this StreamRef stream, Actor actor) { Requires.NotNull(actor, nameof(actor)); var subscriptions = await stream.Subscriptions(); if (subscriptions.Count == 0) { return; } Debug.Assert(subscriptions.Count == 1, "We should keep only one active subscription per-stream per-actor"); await subscriptions[0].Resume(x => actor.Host.Receive(x)); }
public static async Task Subscribe(this StreamRef stream, ActorGrain actor, StreamFilter filter = null) { Requires.NotNull(actor, nameof(actor)); var subscriptions = await stream.Subscriptions(); if (subscriptions.Count == 1) { return; } Debug.Assert(subscriptions.Count == 0, "We should keep only one active subscription per-stream per-actor"); await stream.Subscribe(actor.ReceiveRequest, filter); }
public static async Task Subscribe(this StreamRef stream, Actor actor, StreamFilter filter = null) { Requires.NotNull(actor, nameof(actor)); var subscriptions = await stream.Subscriptions(); if (subscriptions.Count == 1) { return; } Debug.Assert(subscriptions.Count == 0, "We should keep only one active subscription per-stream per-actor"); await stream.Subscribe(x => actor.Host.Receive(x), filter ?? DeclaredHandlerOnlyFilter(actor)); }
public static async Task Resume <TItem, TOptions>(this StreamRef <TItem> stream, ActorGrain actor, TOptions options) where TOptions : ResumeOptions { Requires.NotNull(actor, nameof(actor)); var subscriptions = await stream.Subscriptions(); if (subscriptions.Count == 0) { return; } Debug.Assert(subscriptions.Count == 1, "We should keep only one active subscription per-stream per-actor"); await subscriptions[0].Resume(actor.ReceiveRequest, options); }