public ReadProjectionCheckpointWorker(IProjectionStoreReader reader) { Receive <ReadProjectionCheckpointRequest>(async r => { try { var checkpoint = await reader.ReadProjectionCheckpointAsync(r.ProjectionStream); Sender.Tell(new ReadProjectionCheckpointResponse(r.RequestID, checkpoint)); } finally { Context.Stop(Self); } }); }
public ReadIndexedProjectionStreamWorker(IProjectionStoreReader reader, IPersistedEventFactory factory) { ReceiveRequest <ReadIndexedProjectionStreamRequest>(async(req, sender, ct) => { var checkpoint = await reader.ReadProjectionCheckpointAsync(req.ProjectionStream); var sequence = req.InitialSequence; var globalSequence = 0L; await reader.ReadIndexedProjectionStreamAsync(req.ProjectionStream, req.InitialSequence, req.Count, e => { globalSequence = e.GlobalSequence; var loadedEvent = factory.CreateStreamEvent(e, sequence++); sender.Tell(new ReadIndexedProjectionStreamResponse(req.RequestID, loadedEvent), ActorRefs.NoSender); }, ct); _lastSeenGlobalCheckpoint = Math.Max(checkpoint, globalSequence); }); }