Exemplo n.º 1
0
        public async Task CircuitBreaker_must_publish_ServiceNormal_once_on_event_stream_when_closed()
        {
            Sys.EventStream.Subscribe(probe.Ref, typeof(ServiceEvent));

            breaker.Tell(ServiceEvent.Failed(LogId, 1, TestLogFailureException));
            probe.FishForMessage(msg => msg is ServiceEvent e && e.Type == ServiceEvent.EventType.ServiceFailed);
            breaker.Tell(ServiceEvent.Normal(LogId));
            probe.ExpectMsg(ServiceEvent.Normal(LogId));

            breaker.Tell(ServiceEvent.Normal(LogId));
            probe.ExpectNoMsg(300.Milliseconds());
        }
Exemplo n.º 2
0
        public async Task CircuitBreaker_must_close_again_after_service_success()
        {
            breaker.Tell(ServiceEvent.Failed(LogId, 1, TestLogFailureException));
            try
            {
                await breaker.Ask("a", Timeout);
            }
            catch (AggregateException e) when(e.Flatten().InnerException is EventLogUnavailableException)
            {
                // as expected
            }

            breaker.Tell(ServiceEvent.Normal(LogId));
            (await breaker.Ask("a", Timeout)).Should().Be("re-a");
        }