public StoringAsyncEndpointExecutor(Endpoint endpoint,
                                     ICheckpointer checkpointer,
                                     EndpointExecutorConfig config,
                                     AsyncEndpointExecutorOptions options,
                                     IMessageStore messageStore)
 {
     Preconditions.CheckNotNull(endpoint);
     Preconditions.CheckNotNull(config);
     this.checkpointer    = Preconditions.CheckNotNull(checkpointer);
     this.options         = Preconditions.CheckNotNull(options);
     this.machine         = new EndpointExecutorFsm(endpoint, checkpointer, config);
     this.messageStore    = messageStore;
     this.sendMessageTask = Task.Run(this.SendMessagesPump);
 }
예제 #2
0
 public StoringAsyncEndpointExecutor(
     Endpoint endpoint,
     ICheckpointerFactory checkpointerFactory,
     EndpointExecutorConfig config,
     AsyncEndpointExecutorOptions options,
     IMessageStore messageStore)
 {
     this.Endpoint            = Preconditions.CheckNotNull(endpoint);
     this.checkpointerFactory = Preconditions.CheckNotNull(checkpointerFactory);
     this.config           = Preconditions.CheckNotNull(config);
     this.options          = Preconditions.CheckNotNull(options);
     this.messageStore     = messageStore;
     this.sendMessageTask  = Task.Run(this.SendMessagesPump);
     this.prioritiesToFsms = new AtomicReference <ImmutableDictionary <uint, EndpointExecutorFsm> >(ImmutableDictionary <uint, EndpointExecutorFsm> .Empty);
 }
        public StoringAsyncEndpointExecutor(
            Endpoint endpoint,
            IList <uint> priorities,
            ICheckpointer checkpointer,
            EndpointExecutorConfig config,
            AsyncEndpointExecutorOptions options,
            IMessageStore messageStore)
        {
            Preconditions.CheckNotNull(endpoint);
            Preconditions.CheckNotNull(config);
            Preconditions.CheckNotNull(priorities);
            Preconditions.CheckArgument(priorities.Count != 0);
            this.checkpointer    = Preconditions.CheckNotNull(checkpointer);
            this.options         = Preconditions.CheckNotNull(options);
            this.machine         = new EndpointExecutorFsm(endpoint, checkpointer, config);
            this.messageStore    = messageStore;
            this.sendMessageTask = Task.Run(this.SendMessagesPump);

            this.UpdatePriorities(priorities);
        }
예제 #4
0
        public AsyncEndpointExecutor(Endpoint endpoint, ICheckpointer checkpointer, EndpointExecutorConfig config, AsyncEndpointExecutorOptions options)
        {
            Preconditions.CheckNotNull(endpoint);
            Preconditions.CheckNotNull(config);
            this.checkpointer = Preconditions.CheckNotNull(checkpointer);
            this.cts          = new CancellationTokenSource();
            this.options      = Preconditions.CheckNotNull(options);
            this.machine      = new EndpointExecutorFsm(endpoint, checkpointer, config);
            this.closed       = new AtomicBoolean();

            // The three size variables below adjust the following parameters:
            //    1. MaxMessagesPerTask - the maximum number of messages the batch block will process before yielding
            //    2. BoundedCapacity - the size of the batch blocks input buffer
            //    3. BatchBlock ctor - the maximum size of each batch emitted by the block (can be smaller because of the timer)
            var batchOptions = new GroupingDataflowBlockOptions
            {
                MaxMessagesPerTask = MaxMessagesPerTask,
                BoundedCapacity    = options.BatchSize
            };
            var batchBlock = new BatchBlock <IMessage>(options.BatchSize, batchOptions);

            this.batchTimer = new Timer(Trigger, batchBlock, options.BatchTimeout, options.BatchTimeout);

            var processOptions = new ExecutionDataflowBlockOptions
            {
                BoundedCapacity = 1
            };
            var process = new ActionBlock <IMessage[]>(this.MessagesAction, processOptions);

            var linkOptions = new DataflowLinkOptions {
                PropagateCompletion = true
            };

            batchBlock.LinkTo(process, linkOptions);

            this.head = batchBlock;
            this.tail = process;
        }
 public AsyncEndpointExecutorFactory(EndpointExecutorConfig config, AsyncEndpointExecutorOptions options)
 {
     this.config  = Preconditions.CheckNotNull(config);
     this.options = Preconditions.CheckNotNull(options);
 }
예제 #6
0
 public StoringAsyncEndpointExecutorFactory(EndpointExecutorConfig config, AsyncEndpointExecutorOptions options, IMessageStore messageStore)
 {
     this.config       = Preconditions.CheckNotNull(config, nameof(config));
     this.options      = Preconditions.CheckNotNull(options, nameof(options));
     this.messageStore = Preconditions.CheckNotNull(messageStore, nameof(messageStore));
 }