/// <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(); } }
/// <summary> /// /// </summary> /// <param name="request"></param> /// <param name="body"></param> private void ProcessCommitTransaction(DataStoreRequest request, CommitTransactionPreRequest body) { // Convert hte partial request body into serialized versions of it var types = new HashSet<String>(); var events = new List<String>(); foreach (var evt in body.Events) { var typeNames = evt.GetType().GetInterfaces().Select(it => { return it.Name; }); foreach (var typeName in typeNames) types.Add(typeName); events.Add(serializer.ConvertToString(evt)); } var newRequest = CommitTransactionRequest.Create(events, types.ToList(), body.JournalName, request.Header.RequestUID, body.TransactionUID, request.Header.WorkerUID); newRequest.Write(writer); writer.Flush(); }