public EntityRunner(ICrdtStatefulService service, String entityId, Option <IInternalCrdt> crdt) { Crdt = crdt; EntityId = entityId; Service = service; var ctx = new CrdtEntityCreationContext(); //with CapturingCrdtFactory with ActivatableContext try { Entity = service.Factory.CreateEntityHandler(ctx); } finally { ctx.Deactivate(); } // verifyNoDelta("creation") }
private async Task RunEntity(CrdtInit init, ICrdtStatefulService service, MessageStreamingContext <CrdtStreamIn, CrdtStreamOut> stream) { var state = CrdtStateTransformer.Create(init.State, service.AnySupport).Some(); var runner = new EntityRunner(service, init.EntityId, state); Task ProcessStream(CrdtStreamIn message) { switch (message.MessageCase) { case CrdtStreamIn.MessageOneofCase.Command: runner.HandleCommand(message.Command); break; case CrdtStreamIn.MessageOneofCase.Changed: runner.HandleDelta(message.Changed); break; case CrdtStreamIn.MessageOneofCase.State: break; case CrdtStreamIn.MessageOneofCase.Deleted: break; case CrdtStreamIn.MessageOneofCase.StreamCancelled: break; case CrdtStreamIn.MessageOneofCase.None: case CrdtStreamIn.MessageOneofCase.Init: default: throw new NotImplementedException("Unknown message case"); } return(Task.CompletedTask); } await stream.Request.SelectAsync(ProcessStream); }