Пример #1
0
        public virtual async Task TestBecomeConsumerSlim(Guid streamIdGuid, string streamNamespace, string providerName)
        {
            InitStream(streamIdGuid, streamNamespace, providerName);
            var observer = new MyStreamObserver <int>(logger);

            //var subsHandle = await State.Stream.SubscribeAsync(observer);

            IStreamConsumerExtension myExtensionReference;

#if USE_CAST
            myExtensionReference = StreamConsumerExtensionFactory.Cast(this.AsReference());
#else
            var tup = await runtimeClient.BindExtension <StreamConsumerExtension, IStreamConsumerExtension>(
                () => new StreamConsumerExtension(streamProviderRuntime, _streamProvider.IsRewindable));

            StreamConsumerExtension myExtension = tup.Item1;
            myExtensionReference = tup.Item2;
#endif
            string extKey = providerName + "_" + State.Stream.Namespace;
            IPubSubRendezvousGrain pubsub = GrainFactory.GetGrain <IPubSubRendezvousGrain>(streamIdGuid, extKey, null);
            GuidId subscriptionId         = GuidId.GetNewGuidId();
            await pubsub.RegisterConsumer(subscriptionId, ((StreamImpl <int>)State.Stream).StreamId, myExtensionReference, null);

            myExtension.SetObserver(subscriptionId, ((StreamImpl <int>)State.Stream), observer, null, null);
        }
Пример #2
0
 /// <inheritdoc />
 public Task <Tuple <TExtension, TExtensionInterface> > BindExtension <TExtension, TExtensionInterface>(Func <TExtension> newExtensionFunc) where TExtension : IGrainExtension where TExtensionInterface : IGrainExtension
 {
     return(runtimeClient.BindExtension <TExtension, TExtensionInterface>(newExtensionFunc));
 }