public async Task <IEndpointExecutor> CreateAsync(Endpoint endpoint, ICheckpointer checkpointer, EndpointExecutorConfig endpointExecutorConfig)
        {
            IEndpointExecutor exec = await this.underlying.CreateAsync(endpoint, checkpointer, endpointExecutorConfig);

            await exec.CloseAsync();

            return(exec);
        }
        public async Task <IEndpointExecutor> CreateAsync(Endpoint endpoint, IList <uint> priorities)
        {
            ICheckpointer checkpointer = await Checkpointer.CreateAsync(endpoint.Id, this.store);

            IEndpointExecutor executor = await this.underlying.CreateAsync(endpoint, priorities, checkpointer);

            return(executor);
        }
        public async Task <IEndpointExecutor> CreateAsync(Endpoint endpoint)
        {
            IEndpointExecutor exec = await this.underlying.CreateAsync(endpoint);

            await exec.CloseAsync();

            return(exec);
        }
Ejemplo n.º 4
0
        public async Task <IEndpointExecutor> CreateAsync(Endpoint endpoint, IList <uint> priorities, ICheckpointer checkpointer)
        {
            IEndpointExecutor exec = await this.underlying.CreateAsync(endpoint, priorities, checkpointer);

            await exec.CloseAsync();

            return(exec);
        }
Ejemplo n.º 5
0
            public async Task <IEndpointExecutor> CreateAsync(Endpoint endpoint)
            {
                string        id           = RoutingIdBuilder.Parse(this.idPrefix).Map(prefixTemplate => new RoutingIdBuilder(prefixTemplate.IotHubName, prefixTemplate.RouterNumber, Option.Some(endpoint.Id)).GetId()).GetOrElse(endpoint.Id);
                ICheckpointer checkpointer = await this.checkpointerFactory.CreateAsync(id);

                IEndpointExecutor executor = await this.executorFactory.CreateAsync(endpoint, checkpointer);

                return(executor);
            }
Ejemplo n.º 6
0
        public async Task TestCancellation()
        {
            var endpoint = new StalledEndpoint("id");
            IEndpointExecutor executor = await Factory.CreateAsync(endpoint, null);

            Task running = executor.Invoke(Default, 0, 3600);

            await executor.CloseAsync();

            await running;

            Assert.True(running.IsCompleted);
        }
Ejemplo n.º 7
0
 async Task DispatchInternal(IEndpointExecutor exec, IMessage message)
 {
     try
     {
         await exec.Invoke(message);
     }
     catch (Exception ex) when(ex is InvalidOperationException || ex is OperationCanceledException)
     {
         // disabled
         // Executor is closed, ignore the send
         // TODO add logging?
     }
 }
Ejemplo n.º 8
0
        public async Task TestClose()
        {
            var endpoint = new TestEndpoint("id");
            IEndpointExecutor executor = await Factory.CreateAsync(endpoint, null);

            Task running = executor.Invoke(Default, 0, 3600);

            await executor.CloseAsync();

            await running;

            Assert.True(running.IsCompleted);

            // ensure this doesn't throw
            await executor.CloseAsync();
        }
Ejemplo n.º 9
0
        public async Task TestSetEndpoint()
        {
            var endpoint1 = new TestEndpoint("id1");
            var endpoint2 = new TestEndpoint("id1");
            var endpoint3 = new TestEndpoint("id3");
            IEndpointExecutor executor = await Factory.CreateAsync(endpoint1);

            Assert.Equal(new List <IMessage>(), endpoint1.Processed);
            Assert.Equal(new List <IMessage>(), endpoint2.Processed);
            Assert.Equal(new List <IMessage>(), endpoint3.Processed);
            await Assert.ThrowsAsync <ArgumentException>(() => executor.SetEndpoint(endpoint3));

            await executor.Invoke(Message1);

            await executor.Invoke(Message1);

            Assert.Equal(new List <IMessage> {
                Message1, Message1
            }, endpoint1.Processed);
            Assert.Equal(new List <IMessage>(), endpoint2.Processed);
            Assert.Equal(new List <IMessage>(), endpoint3.Processed);

            await executor.SetEndpoint(endpoint2);

            Assert.Equal(new List <IMessage> {
                Message1, Message1
            }, endpoint1.Processed);
            Assert.Equal(new List <IMessage>(), endpoint2.Processed);
            Assert.Equal(new List <IMessage>(), endpoint3.Processed);

            await executor.Invoke(Message2);

            await executor.Invoke(Message3);

            Assert.Equal(new List <IMessage> {
                Message1, Message1
            }, endpoint1.Processed);
            Assert.Equal(new List <IMessage> {
                Message2, Message3
            }, endpoint2.Processed);
            Assert.Equal(new List <IMessage>(), endpoint3.Processed);

            await executor.CloseAsync();
        }
Ejemplo n.º 10
0
        public async Task TestSetEndpoint()
        {
            var endpoint1 = new TestEndpoint("id");
            var endpoint2 = new NullEndpoint("id");
            var endpoint3 = new TestEndpoint("id1");
            IEndpointExecutor executor = await Factory.CreateAsync(endpoint1, null);

            Assert.Equal(endpoint1, executor.Endpoint);
            await Assert.ThrowsAsync <ArgumentNullException>(() => executor.SetEndpoint(null, null));

            await Assert.ThrowsAsync <ArgumentException>(() => executor.SetEndpoint(endpoint3, null));

            await executor.SetEndpoint(endpoint2, null);

            Assert.Equal(endpoint2, executor.Endpoint);

            await executor.CloseAsync();

            await Assert.ThrowsAsync <InvalidOperationException>(() => executor.SetEndpoint(endpoint1, null));
        }
Ejemplo n.º 11
0
        public async Task TestClose()
        {
            var endpoint = new TestEndpoint("id");
            IEndpointExecutor executor = await Factory.CreateAsync(endpoint);

            Task running = executor.Invoke(Default);

            await executor.CloseAsync();

            await running;

            Assert.True(running.IsCompleted);

            // ensure this doesn't throw
            await executor.CloseAsync();

            await Assert.ThrowsAsync <InvalidOperationException>(() => executor.Invoke(Default));

            await Assert.ThrowsAsync <InvalidOperationException>(() => executor.SetEndpoint(endpoint));
        }