public void Handle(CoreProjectionManagementMessage.CreatePrepared message) { try { var name = message.Name; var sourceDefinition = ProjectionSourceDefinition.From( name, message.SourceDefinition, message.HandlerType, message.Query); var projectionVersion = message.Version; var projectionConfig = message.Config; var namesBuilder = new ProjectionNamesBuilder(name, sourceDefinition); var projectionProcessingStrategy = _processingStrategySelector.CreateProjectionProcessingStrategy( name, projectionVersion, namesBuilder, sourceDefinition, projectionConfig, null, null); var slaveProjections = projectionProcessingStrategy.GetSlaveProjections(); CreateCoreProjection(message.ProjectionId, projectionConfig.RunAs, projectionProcessingStrategy); message.Envelope.ReplyWith( new CoreProjectionManagementMessage.Prepared( message.ProjectionId, sourceDefinition, slaveProjections)); } catch (Exception ex) { message.Envelope.ReplyWith( new CoreProjectionManagementMessage.Faulted(message.ProjectionId, ex.Message)); } }
public void Handle(CoreProjectionManagementMessage.CreatePrepared message) { try { var name = message.Name; var sourceDefinition = ProjectionSourceDefinition.From(message.SourceDefinition); var projectionVersion = message.Version; var projectionConfig = message.Config; var namesBuilder = new ProjectionNamesBuilder(name, sourceDefinition); var projectionProcessingStrategy = _processingStrategySelector.CreateProjectionProcessingStrategy( name, projectionVersion, namesBuilder, sourceDefinition, projectionConfig, null, message.HandlerType, message.Query); CreateCoreProjection(message.ProjectionId, projectionConfig.RunAs, projectionProcessingStrategy); _publisher.Publish( new CoreProjectionStatusMessage.Prepared( message.ProjectionId, sourceDefinition)); } catch (Exception ex) { _publisher.Publish( new CoreProjectionStatusMessage.Faulted(message.ProjectionId, ex.Message)); } }
public void Handle(CoreProjectionManagementMessage.CreateAndPrepare message) { try { //TODO: factory method can throw IProjectionStateHandler stateHandler = message.HandlerFactory(); string name = message.Name; var sourceDefinition = ProjectionSourceDefinition.From( name, stateHandler.GetSourceDefinition(), message.HandlerType, message.Query); var projectionVersion = message.Version; var projectionConfig = message.Config; var namesBuilder = new ProjectionNamesBuilder(name, sourceDefinition); var projectionProcessingStrategy = _processingStrategySelector.CreateProjectionProcessingStrategy( name, projectionVersion, namesBuilder, sourceDefinition, projectionConfig, message.HandlerFactory, stateHandler); var slaveProjections = projectionProcessingStrategy.GetSlaveProjections(); CreateCoreProjection(message.ProjectionId, projectionConfig.RunAs, projectionProcessingStrategy); message.Envelope.ReplyWith( new CoreProjectionManagementMessage.Prepared( message.ProjectionId, sourceDefinition, slaveProjections)); } catch (Exception ex) { message.Envelope.ReplyWith( new CoreProjectionManagementMessage.Faulted(message.ProjectionId, ex.Message)); } }
public void Handle(CoreProjectionManagementMessage.CreateAndPrepareSlave message) { try { //TODO: factory method can throw! IProjectionStateHandler stateHandler = message.HandlerFactory(); string name = message.Name; var sourceDefinition = ProjectionSourceDefinition.From(name, stateHandler.GetSourceDefinition(), null, null); var projectionVersion = message.Version; var projectionConfig = message.Config.SetIsSlave(); var projectionProcessingStrategy = _processingStrategySelector.CreateSlaveProjectionProcessingStrategy( name, projectionVersion, sourceDefinition, projectionConfig, stateHandler, message.ResultsPublisher, message.MasterCoreProjectionId, this); CreateCoreProjection(message.ProjectionId, projectionConfig.RunAs, projectionProcessingStrategy); message.Envelope.ReplyWith( new CoreProjectionManagementMessage.Prepared( message.ProjectionId, sourceDefinition, slaveProjections: null)); } catch (Exception ex) { message.Envelope.ReplyWith( new CoreProjectionManagementMessage.Faulted(message.ProjectionId, ex.Message)); } }
public void Handle(CoreProjectionManagementMessage.CreateAndPrepareSlave message) { try { var stateHandler = CreateStateHandler(_timeoutScheduler, _logger, message.HandlerType, message.Query); string name = message.Name; var sourceDefinition = ProjectionSourceDefinition.From(stateHandler.GetSourceDefinition()); var projectionVersion = message.Version; var projectionConfig = message.Config.SetIsSlave(); var projectionProcessingStrategy = _processingStrategySelector.CreateSlaveProjectionProcessingStrategy( name, projectionVersion, sourceDefinition, projectionConfig, stateHandler, message.MasterWorkerId, _publisher, message.MasterCoreProjectionId, this); CreateCoreProjection(message.ProjectionId, projectionConfig.RunAs, projectionProcessingStrategy); _publisher.Publish( new CoreProjectionStatusMessage.Prepared( message.ProjectionId, sourceDefinition)); } catch (Exception ex) { _publisher.Publish(new CoreProjectionStatusMessage.Faulted(message.ProjectionId, ex.Message)); } }
protected bool Equals(ProjectionSourceDefinition other) { return(AllEvents.Equals(other.AllEvents) && AllStreams.Equals(other.AllStreams) && ByStream.Equals(other.ByStream) && ByCustomPartitions.Equals(other.ByCustomPartitions) && Equals(Categories, other.Categories) && Equals(Events, other.Events) && Equals(Streams, other.Streams) && string.Equals(CatalogStream, other.CatalogStream) && LimitingCommitPosition == other.LimitingCommitPosition && Equals(Options, other.Options)); }
public ProjectionProcessingStrategy CreateSlaveProjectionProcessingStrategy( string name, ProjectionVersion projectionVersion, ProjectionSourceDefinition sourceDefinition, ProjectionConfig projectionConfig, IProjectionStateHandler stateHandler, IPublisher resultsEnvelope, Guid masterCoreProjectionId, ProjectionCoreService projectionCoreService) { return new SlaveQueryProcessingStrategy( name, projectionVersion, stateHandler, projectionConfig, sourceDefinition, projectionCoreService.Logger, resultsEnvelope, masterCoreProjectionId, _subscriptionDispatcher); }
public ProjectionProcessingStrategy CreateSlaveProjectionProcessingStrategy( string name, ProjectionVersion projectionVersion, ProjectionSourceDefinition sourceDefinition, ProjectionConfig projectionConfig, IProjectionStateHandler stateHandler, IPublisher resultsEnvelope, Guid masterCoreProjectionId, ProjectionCoreService projectionCoreService) { return(new SlaveQueryProcessingStrategy( name, projectionVersion, stateHandler, projectionConfig, sourceDefinition, projectionCoreService.Logger, resultsEnvelope, masterCoreProjectionId, _subscriptionDispatcher)); }
protected override void Given() { _projectionId = Guid.NewGuid(); var builder = new SourceDefinitionBuilder(); builder.FromStream("s1"); builder.FromStream("s2"); builder.IncludeEvent("e1"); builder.IncludeEvent("e2"); builder.SetByStream(); builder.SetResultStreamNameOption("result-stream"); _definition = ProjectionSourceDefinition.From(builder); }
public void Handle(CoreProjectionManagementMessage.CreateAndPrepare message) { try { //TODO: factory method can throw var stateHandler = CreateStateHandler( _timeoutScheduler, _logger, message.HandlerType, message.Query); string name = message.Name; var sourceDefinition = ProjectionSourceDefinition.From(stateHandler.GetSourceDefinition()); var projectionVersion = message.Version; var projectionConfig = message.Config; var namesBuilder = new ProjectionNamesBuilder(name, sourceDefinition); var projectionProcessingStrategy = _processingStrategySelector.CreateProjectionProcessingStrategy( name, projectionVersion, namesBuilder, sourceDefinition, projectionConfig, stateHandler, message.HandlerType, message.Query); CreateCoreProjection(message.ProjectionId, projectionConfig.RunAs, projectionProcessingStrategy); _publisher.Publish( new CoreProjectionStatusMessage.Prepared( message.ProjectionId, sourceDefinition)); } catch (Exception ex) { _publisher.Publish( new CoreProjectionStatusMessage.Faulted(message.ProjectionId, ex.Message)); } }
public Prepared(Guid projectionId, ProjectionSourceDefinition sourceDefinition) : base(projectionId) { _sourceDefinition = sourceDefinition; }
public ProjectionQuery(string name, string query, bool emitEnabled, ProjectionSourceDefinition definition, ProjectionOutputConfig outputConfig) { _name = name; _query = query; _emitEnabled = emitEnabled; _definition = definition; _outputConfig = outputConfig; }
public Prepared( Guid projectionId, ProjectionSourceDefinition sourceDefinition, SlaveProjectionDefinitions slaveProjections) : base(projectionId) { _sourceDefinition = sourceDefinition; _slaveProjections = slaveProjections; }
public ProjectionQuery(string name, string query, bool emitEnabled, ProjectionSourceDefinition definition) { _name = name; _query = query; _emitEnabled = emitEnabled; _definition = definition; }
protected bool Equals(ProjectionSourceDefinition other) { return AllEvents.Equals(other.AllEvents) && AllStreams.Equals(other.AllStreams) && ByStream.Equals(other.ByStream) && ByCustomPartitions.Equals(other.ByCustomPartitions) && Equals(Categories, other.Categories) && Equals(Events, other.Events) && Equals(Streams, other.Streams) && string.Equals(CatalogStream, other.CatalogStream) && LimitingCommitPosition == other.LimitingCommitPosition && Equals(Options, other.Options); }
public SourceDefinition(ProjectionSourceDefinition sourceDefinition) { if (sourceDefinition == null) throw new ArgumentNullException("sourceDefinition"); _sourceDefinition = sourceDefinition; }