Exemple #1
0
 public CircuitBreakerOpen(CircuitBreakerRepository owner)
     : base(owner)
 {
     new Timer(_ =>
     {
         owner._state = new CircuitBreakerHalfOpen(owner);
     }, null, Config.CircuitOpenTimeout, Timeout.Infinite);
 }
Exemple #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);
            }
        }
Exemple #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);
            }
        }
Exemple #4
0
 public CircuitBreakerClosed(CircuitBreakerRepository owner)
     : base(owner)
 {
 }
Exemple #5
0
 public CircuitBreakerState(CircuitBreakerRepository owner)
 {
     _owner = owner;
 }
Exemple #6
0
 public CircuitBreakerHalfOpen(CircuitBreakerRepository owner)
     : base(owner)
 {
 }