Exemple #1
0
 public TestBreaker( CircuitBreaker instance )
 {
     HalfOpenLatch = new CountdownEvent( 1 );
     OpenLatch = new CountdownEvent( 1 );
     ClosedLatch = new CountdownEvent( 1 );
     Instance = instance;
     Instance.OnClose( ( ) => { if ( !ClosedLatch.IsSet ) ClosedLatch.Signal( ); } )
             .OnHalfOpen( ( ) => { if ( !HalfOpenLatch.IsSet ) HalfOpenLatch.Signal( ); } )
             .OnOpen( ( ) => { if ( !OpenLatch.IsSet ) OpenLatch.Signal( ); } );
 }
Exemple #2
0
        protected SnapshotStore()
        {
            var extension = Persistence.Instance.Apply(Context.System);
            if (extension == null)
            {
                throw new ArgumentException("Couldn't initialize SnapshotStore instance, because associated Persistence extension has not been used in current actor system context.");
            }

            _publish = extension.Settings.Internal.PublishPluginCommands;
            var config = extension.ConfigFor(Self);
            _breaker = CircuitBreaker.Create(
                config.GetInt("circuit-breaker.max-failures"),
                config.GetTimeSpan("circuit-breaker.call-timeout"),
                config.GetTimeSpan("circuit-breaker.reset-timeout"));
        }
        protected AsyncWriteJournal()
        {
            var extension = Persistence.Instance.Apply(Context.System);
            if (extension == null)
            {
                throw new ArgumentException("Couldn't initialize SyncWriteJournal instance, because associated Persistence extension has not been used in current actor system context.");
            }

            CanPublish = extension.Settings.Internal.PublishPluginCommands;
            var config = extension.ConfigFor(Self);
            _breaker = new CircuitBreaker(
                config.GetInt("circuit-breaker.max-failures"),
                config.GetTimeSpan("circuit-breaker.call-timeout"),
                config.GetTimeSpan("circuit-breaker.reset-timeout")
                );

            var replayFilterMode = config.GetString("replay-filter.mode").ToLower();
            switch (replayFilterMode)
            {
                case "off":
                    _replayFilterMode = ReplayFilterMode.Disabled;
                    break;
                case "repair-by-discard-old":
                    _replayFilterMode = ReplayFilterMode.RepairByDiscardOld;
                    break;
                case "fail":
                    _replayFilterMode = ReplayFilterMode.Fail;
                    break;
                case "warn":
                    _replayFilterMode = ReplayFilterMode.Warn;
                    break;
                default:
                    throw new ArgumentException(string.Format("Invalid replay-filter.mode [{0}], supported values [off, repair-by-discard-old, fail, warn]", replayFilterMode));
            }
            _isReplayFilterEnabled = _replayFilterMode != ReplayFilterMode.Disabled;
            _replayFilterWindowSize = config.GetInt("replay-filter.window-size");
            _replayFilterMaxOldWriters = config.GetInt("replay-filter.max-old-writers");
            _replayDebugEnabled = config.GetBoolean("replay-filter.debug");

            _resequencer = Context.System.ActorOf(Props.Create(() => new Resequencer()));
        }
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="breaker">TBD</param>
 public HalfOpen(CircuitBreaker breaker)
     : base(breaker.CallTimeout, 0)
 {
     _breaker = breaker;
     _lock    = new AtomicBoolean();
 }
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="breaker">TBD</param>
 public Open(CircuitBreaker breaker)
     : base(breaker.CallTimeout, 0)
 {
     _breaker = breaker;
 }
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="breaker">TBD</param>
 public Closed(CircuitBreaker breaker)
     : base(breaker.CallTimeout, 0)
 {
     _breaker = breaker;
 }