Exemplo n.º 1
0
 public CircuitBreakerOpen(CircuitBreakerRepository owner)
     : base(owner)
 {
     new Timer(_ =>
     {
         owner._state = new CircuitBreakerHalfOpen(owner);
     }, null, Config.CircuitOpenTimeout, Timeout.Infinite);
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            // Create a circuit breaker repository
            IPersonRepository repository = new CircuitBreakerRepository(DatabaseConnectionFactory.Connection);

            for (int i = 0; i < 100; i++)
            {
                try
                {
                    ReadOrWrite(repository, i);
                }
                catch (Exception e)
                {
                    Console.WriteLine($"{e.GetType().FullName}: {e.Message}");
                }
                Thread.Sleep(800);
            }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            int requestToSend = 100;
            // Create a circuit breaker repository
            IOrderRepository repository = new CircuitBreakerRepository(ServiceConnectionFactory.Connection);

            for (int i = 0; i < requestToSend; i++)
            {
                try
                {
                    ReadOrWrite(repository, i);
                }
                catch (Exception e)
                {
                    Console.WriteLine($"{e.GetType().FullName}: {e.Message}");
                }
                Thread.Sleep(1000);
            }
        }
Exemplo n.º 4
0
 public CircuitBreakerClosed(CircuitBreakerRepository owner)
     : base(owner)
 {
 }
Exemplo n.º 5
0
 public CircuitBreakerState(CircuitBreakerRepository owner)
 {
     _owner = owner;
 }
Exemplo n.º 6
0
 public CircuitBreakerHalfOpen(CircuitBreakerRepository owner)
     : base(owner)
 {
 }