예제 #1
0
        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();
        }
예제 #2
0
        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));
        }
예제 #3
0
        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);
        }
예제 #4
0
        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));
        }
예제 #5
0
        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);
        }