public Task RegisterConsumer(GuidId subscriptionId, StreamId streamId, string streamProvider, IStreamConsumerExtension streamConsumer, IStreamFilterPredicateWrapper filter)
 {
     if (!IsImplicitSubscriber(streamConsumer, streamId))
     {
         throw new ArgumentOutOfRangeException(streamId.ToString(), "Only implicit subscriptions are supported.");
     }
     return TaskDone.Done;
 }
Example #2
0
 public Task<List<GuidId>> GetAllSubscriptions(StreamId streamId, IStreamConsumerExtension streamConsumer)
 {
     if (!IsImplicitSubscriber(streamConsumer, streamId))
     {
         throw new ArgumentOutOfRangeException(streamId.ToString(), "Only implicit subscriptions are supported.");
     }
     return Task.FromResult(new List<GuidId> { GuidId.GetGuidId(streamConsumer.GetPrimaryKey()) });
 }
 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);
 }
            public StreamAction ToEventStream()
            {
                if (Store.Events.StreamIdentity == StreamIdentity.AsGuid)
                {
                    var stream = StreamAction.Start(StreamId, new AEvent());
                    stream.TenantId = TenantId;

                    return(stream);
                }
                else
                {
                    var stream = StreamAction.Start(StreamId.ToString(), new AEvent());
                    stream.TenantId = TenantId;

                    return(stream);
                }
            }
        /// <summary>
        /// Returns a <see cref="string" /> that represents this stream specifier.
        /// </summary>
        /// <returns>
        /// A <see cref="string" /> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            if (string.IsNullOrWhiteSpace(StreamSuffix) == false && StreamId >= 0)
            {
                return($"{StreamSuffix}:{StreamId}");
            }

            if (string.IsNullOrWhiteSpace(StreamSuffix) == false)
            {
                return(StreamSuffix);
            }

            if (StreamId >= 0)
            {
                return(StreamId.ToString(CultureInfo.InvariantCulture));
            }

            return(string.Empty);
        }
            public StreamAction StartNewStream(IMartenSessionLogger logger = null)
            {
                var events = new object[] { new AEvent(), new BEvent(), new CEvent(), new DEvent() };

                using var session = Store.Events.TenancyStyle == TenancyStyle.Conjoined
                    ? Store.LightweightSession(TenantId)
                    : Store.LightweightSession();

                session.Listeners.Add(new EventMetadataChecker());

                if (logger != null)
                {
                    session.Logger = logger;
                }

                if (Store.Events.StreamIdentity == StreamIdentity.AsGuid)
                {
                    session.Events.StartStream(StreamId, events);
                    session.SaveChanges();

                    var stream = StreamAction.Append(StreamId);
                    stream.Version  = 4;
                    stream.TenantId = TenantId;

                    return(stream);
                }
                else
                {
                    session.Events.StartStream(StreamId.ToString(), events);
                    session.SaveChanges();

                    var stream = StreamAction.Start(StreamId.ToString(), new AEvent());
                    stream.Version  = 4;
                    stream.TenantId = TenantId;

                    return(stream);
                }
            }
 /// <summary>
 /// 接收消息
 /// </summary>
 /// <param name="content">消息内容</param>
 /// <param name="token">StreamSequenceToken</param>
 protected override Task OnReceiving(IsOperationPoint content, StreamSequenceToken token)
 {
     UserMessage.Send(StreamId.ToString(), Name, Utilities.JsonSerialize(content));
     return(Task.CompletedTask);
 }
 public override string ToString()
 {
     return(StreamId.ToString());
 }