internal static DataStoreRequest Create(string journalName, Offset offset, Offset journalSize, RequestUID requestUID, WorkerUID workerUID) { var request = new ReadJournalRequest(journalName, offset, journalSize); var header = new Header(RequestType.READ_JOURNAL, request.SizeOf, requestUID, HeaderProperties.None, workerUID); return new DataStoreRequest(header, request); }
/// <summary> /// /// </summary> /// <param name="request"></param> /// <param name="body"></param> private void ProcessReadJournalRequest(DataStoreRequest request, ReadJournalRequest body) { var snapshot = snapshotManager.FlatSelect((manager) => { return manager.LoadSnapshot(body.JournalName); }); if (snapshot.IsDefined) { var promise = mapper.RemoveAndGet(request.Header.RequestUID); var entry = snapshot.Value; // TODO: Read any events left from the server (if new events is available) var result = new DataStoreResponse(request.Header, new ReadJournalSnapshotResponse(entry.JournalSize, entry.Events)); promise.Success(result); } else { request.Write(writer); writer.Flush(); } }