public GuidId CreateSubscriptionId(StreamId streamId, IStreamConsumerExtension streamConsumer)
        {
            GrainId grainId = GrainExtensions.GetGrainId(streamConsumer);
            Guid    subscriptionGuid;

            if (!implicitTable.TryGetImplicitSubscriptionGuid(grainId, streamId, out subscriptionGuid))
            {
                throw new ArgumentOutOfRangeException(streamId.ToString(), "Only implicit subscriptions are supported.");
            }
            return(GuidId.GetGuidId(subscriptionGuid));
        }
Esempio n. 2
0
        public GuidId CreateSubscriptionId(IAddressable requesterAddress, StreamId streamId)
        {
            GrainId grainId = GrainExtensions.GetGrainId(requesterAddress);
            Guid    subscriptionId;

            if (!implicitPubSub.TryGetImplicitSubscriptionGuid(grainId, streamId, out subscriptionId))
            {
                subscriptionId = SubscriptionMarker.MarkAsExplicitSubscriptionId(Guid.NewGuid());
            }
            return(GuidId.GetGuidId(subscriptionId));
        }
Esempio n. 3
0
        public GuidId CreateSubscriptionId(IAddressable requesterAddress, StreamId streamId)
        {
            GrainId grainId = GrainExtensions.GetGrainId(requesterAddress);

            // If there is an implicit subscription setup for the provided grain on this provided stream, subscription should match the stream Id.
            // If there is no implicit subscription setup, generate new random unique subscriptionId.
            // TODO: Replace subscription id with statically generated subscriptionId instead of getting it from the streamId.
            return(implicitPubSub.IsImplicitSubscriber(grainId, streamId)
                ? GuidId.GetGuidId(grainId.GetPrimaryKey())
                : GuidId.GetNewGuidId());
        }
Esempio n. 4
0
        public async Task <ISet <PubSubSubscriptionState> > RegisterProducer(StreamId streamId, string streamProvider, IStreamProducerExtension streamProducer)
        {
            ISet <PubSubSubscriptionState> result = await explicitPubSub.RegisterProducer(streamId, streamProvider, streamProducer);

            if (String.IsNullOrWhiteSpace(streamId.Namespace))
            {
                return(result);
            }

            ISet <IStreamConsumerExtension> implicitSet = implicitPubSub.GetImplicitSubscribers(streamId);

            foreach (var consumer in implicitSet)
            {
                // we ignore duplicate entries-- there's no way a programmer could prevent the duplicate entry from being added if we threw an exception to communicate the problem.
                GuidId subscriptionId = GuidId.GetGuidId(GrainExtensions.GetGrainId(consumer).GetPrimaryKey());
                result.Add(new PubSubSubscriptionState(subscriptionId, streamId, consumer, null, null));
            }
            return(result);
        }
 internal bool IsImplicitSubscriber(IAddressable addressable, StreamId streamId)
 {
     return(implicitTable.IsImplicitSubscriber(GrainExtensions.GetGrainId(addressable), streamId));
 }
Esempio n. 6
0
 private bool IsImplicitSubscriber(IAddressable addressable, StreamId streamId)
 {
     return(implicitPubSub.IsImplicitSubscriber(GrainExtensions.GetGrainId(addressable), streamId));
 }