private bool ProcessEventByHandler( string partition, EventReaderSubscriptionMessage.CommittedEventReceived message, out string newState, out string projectionResult, out EmittedEventEnvelope[] emittedEvents) { projectionResult = null; SetHandlerState(partition); _stopwatch.Start(); var result = _projectionStateHandler.ProcessEvent( partition, message.CheckpointTag, message.EventCategory, message.Data, out newState, out emittedEvents); if (result) { var oldState = _partitionStateCache.GetLockedPartitionState(partition); //TODO: depending on query processing final state to result transformation should happen either here (if EOF) on while writing results if (/*_producesRunningResults && */ oldState.State != newState) { if (_definesStateTransform) { projectionResult = _projectionStateHandler.TransformStateToResult(); } else { projectionResult = newState; } } else { projectionResult = oldState.Result; } } _stopwatch.Stop(); return(result); }
private bool ProcessEventByHandler( string partition, EventReaderSubscriptionMessage.CommittedEventReceived message, out string newState, out string newSharedState, out string projectionResult, out EmittedEventEnvelope[] emittedEvents) { projectionResult = null; var newPatitionInitialized = InitOrLoadHandlerState(partition); _stopwatch.Start(); EmittedEventEnvelope[] eventsEmittedOnInitialization = null; if (newPatitionInitialized) { _projectionStateHandler.ProcessPartitionCreated( partition, message.CheckpointTag, message.Data, out eventsEmittedOnInitialization); } var result = _projectionStateHandler.ProcessEvent( partition, message.CheckpointTag, message.EventCategory, message.Data, out newState, out newSharedState, out emittedEvents); if (result) { var oldState = _partitionStateCache.GetLockedPartitionState(partition); //TODO: depending on query processing final state to result transformation should happen either here (if EOF) on while writing results if (/*_producesRunningResults && */ oldState.State != newState) { if (_definesStateTransform) { projectionResult = _projectionStateHandler.TransformStateToResult(); } else { projectionResult = newState; } } else { projectionResult = oldState.Result; } } _stopwatch.Stop(); if (eventsEmittedOnInitialization != null) { if (emittedEvents == null || emittedEvents.Length == 0) { emittedEvents = eventsEmittedOnInitialization; } else { emittedEvents = eventsEmittedOnInitialization.Concat(emittedEvents).ToArray(); } } return(result); }
public static bool ProcessEvent( this IProjectionStateHandler self, string partition, CheckpointTag eventPosition, string streamId, string eventType, string category, Guid eventId, long eventSequenceNumber, string metadata, string data, out string state, out string sharedState, out EmittedEventEnvelope[] emittedEvents, bool isJson = true) { return(self.ProcessEvent( partition, eventPosition, category, new ResolvedEvent( streamId, eventSequenceNumber, streamId, eventSequenceNumber, false, new TFPos(0, -1), eventId, eventType, isJson, data, metadata), out state, out sharedState, out emittedEvents)); }
private bool ProcessEventByHandler( string partition, ProjectionMessage.Projections.CommittedEventReceived message, out string newState, out EmittedEvent[] emittedEvents) { SetHandlerState(partition); return(_projectionStateHandler.ProcessEvent( message.Position, message.EventStreamId, message.Data.EventType, _eventFilter.GetCategory(message.PositionStreamId), message.Data.EventId, message.EventSequenceNumber, Encoding.UTF8.GetString(message.Data.Metadata), Encoding.UTF8.GetString(message.Data.Data), out newState, out emittedEvents)); }