public void setup() { var builder = new CheckpointStrategy.Builder(); builder.FromAll(); builder.AllEvents(); _strategy = builder.Build(ProjectionMode.Persistent); }
protected CheckpointStrategy CreateCheckpointStrategy() { var result = new CheckpointStrategy.Builder(); result.FromAll(); result.AllEvents(); return(result.Build(ProjectionMode.Persistent)); }
public void it_can_be_created() { var builder = new CheckpointStrategy.Builder(); builder.FromAll(); builder.AllEvents(); var cs = builder.Build(ProjectionMode.Persistent); }
private void BeginCreateAndPrepare( ProjectionStateHandlerFactory handlerFactory, ProjectionConfig config, Action onPrepared) { _onPrepared = onPrepared; if (handlerFactory == null) { throw new ArgumentNullException("handlerFactory"); } if (config == null) { throw new ArgumentNullException("config"); } //TODO: which states are allowed here? if (_state >= ManagedProjectionState.Preparing) { throw new InvalidOperationException("Already preparing or has been prepared"); } //TODO: load configuration from the definition var createProjectionMessage = new CoreProjectionManagementMessage.CreateAndPrepare( new PublishEnvelope(_inputQueue), _id, _name, config, delegate { // this delegate runs in the context of a projection core thread // TODO: move this code to the projection core service as we may be in different processes in the future IProjectionStateHandler stateHandler = null; try { stateHandler = handlerFactory.Create(HandlerType, Query, Console.WriteLine); var checkpointStrategyBuilder = new CheckpointStrategy.Builder(); stateHandler.ConfigureSourceProcessingStrategy(checkpointStrategyBuilder); checkpointStrategyBuilder.Validate(Mode); // avoid future exceptions in coreprojection return(stateHandler); } catch (Exception ex) { SetFaulted( string.Format( "Cannot create a projection state handler.\r\n\r\nHandler type: {0}\r\nQuery:\r\n\r\n{1}\r\n\r\nMessage:\r\n\r\n{2}", HandlerType, Query, ex.Message), ex); if (stateHandler != null) { stateHandler.Dispose(); } throw; } }); //note: set runnign before start as coreProjection.start() can respond with faulted _state = ManagedProjectionState.Preparing; _coreQueue.Publish(createProjectionMessage); }
private void Start(IPublisher coreOutput, ProjectionStateHandlerFactory handlerFactory, ProjectionConfig config) { if (coreOutput == null) { throw new ArgumentNullException("coreOutput"); } if (handlerFactory == null) { throw new ArgumentNullException("handlerFactory"); } if (config == null) { throw new ArgumentNullException("config"); } if (_coreProjection != null) { throw new InvalidOperationException("CoreProjection has been already created"); } IProjectionStateHandler stateHandler = null; try { stateHandler = handlerFactory.Create(HandlerType, Query, Console.WriteLine); var checkpointStrategyBuilder = new CheckpointStrategy.Builder(); stateHandler.ConfigureSourceProcessingStrategy(checkpointStrategyBuilder); checkpointStrategyBuilder.Validate(this.Mode); // avoid future exceptions in coreprojection // constructor can fail if wrong source defintion //TODO: revise it _coreProjection = new CoreProjection(_name, _id, coreOutput, stateHandler, config, _logger); } catch (Exception ex) { SetFaulted( String.Format( "Cannot create a projection state handler.\r\n\r\nHandler type: {0}\r\nQuery:\r\n\r\n{1}\r\n\r\nMessage:\r\n\r\n{2}", HandlerType, Query, ex.Message), ex); if (stateHandler != null) { stateHandler.Dispose(); } return; } //TODO: load configuration from the definition _state = ManagedProjectionState.Running; //note: set runnign before start as coreProjection.start() can respond with faulted _coreProjection.Start(); }
private CheckpointStrategy CreateCheckpointStrategy() { var result = new CheckpointStrategy.Builder(); if (_source != null) { _source(result); } else { result.FromAll(); result.AllEvents(); } return(result.Build(ProjectionMode.Persistent)); }
private void Start(ProjectionStateHandlerFactory handlerFactory, ProjectionConfig config) { if (handlerFactory == null) { throw new ArgumentNullException("handlerFactory"); } if (config == null) { throw new ArgumentNullException("config"); } if (_state == ManagedProjectionState.Running) { throw new InvalidOperationException("Already started"); } //TODO: load configuration from the definition var createProjectionMessage = new ProjectionMessage.CoreService.Management.Create(new PublishEnvelope(_inputQueue), _id, _name, config, delegate { IProjectionStateHandler stateHandler = null; try { stateHandler = handlerFactory.Create(this.HandlerType, this.Query, Console.WriteLine); var checkpointStrategyBuilder = new CheckpointStrategy.Builder(); stateHandler.ConfigureSourceProcessingStrategy(checkpointStrategyBuilder); checkpointStrategyBuilder.Validate(Mode); // avoid future exceptions in coreprojection return(stateHandler); } catch (Exception ex) { SetFaulted(String.Format("Cannot create a projection state handler.\r\n\r\nHandler type: {0}\r\nQuery:\r\n\r\n{1}\r\n\r\nMessage:\r\n\r\n{2}", HandlerType, Query, ex.Message), ex); if (stateHandler != null) { stateHandler.Dispose(); } throw; } }); //note: set runnign before start as coreProjection.start() can respond with faulted _state = ManagedProjectionState.Running; _coreQueue.Publish(createProjectionMessage); _coreQueue.Publish(new ProjectionMessage.Projections.Management.Start(_id)); }
protected virtual CheckpointStrategy CreateCheckpointStrategy() { var result = new CheckpointStrategy.Builder(); var readerBuilder = new ReaderStrategy.Builder(); if (_source != null) { _source(readerBuilder); _source(result); } else { readerBuilder.FromAll(); readerBuilder.AllEvents(); result.FromAll(); result.AllEvents(); } var config = ProjectionConfig.GetTest(); return(result.Build(config, null, readerBuilder.Build(new RealTimeProvider(), runAs: null))); }
public void Setup() { _builder = new CheckpointStrategy.Builder(); Given(); When(); }