public Exception Fail(string errorMessage) { ActivatableContext.CheckActive(); if (!Error.HasValue) { Error = Optional.Option.Some(errorMessage); throw new FailInvokedException(); } throw new InvalidOperationException("fail(…) already previously invoked!"); }
public void Emit(object @event) { ActivatableContext.CheckActive(); var anyEvent = Any.Pack(@event as IMessage); // TODO: might not be Imessage, may need to pack it. var nextSequenceNumber = Sequence + Events.Count + 1; EventSourcedEntityHandler.HandleEvent( anyEvent, new EventContext(EntityId, nextSequenceNumber, AbstractContext) ); Events.Add(anyEvent); PerformSnapshot = (SnapshotEvery > 0) && (PerformSnapshot || (nextSequenceNumber % SnapshotEvery == 0)); }
public void Forward(IServiceCall to) { ActivatableContext.CheckActive(); if (ForwardMessage.HasValue) { throw new InvalidOperationException("This context has already forwarded."); } ForwardMessage = Optional.Option.Some( new Forward { ServiceName = to.Ref.Method.Service.FullName, CommandName = to.Ref.Method.Name, Payload = Any.Pack(to.Message) } ); }