internal SupervisorStrategy SupervisorStrategyLazy()
        {
            if (supervisorStrategy == null)
                supervisorStrategy = SupervisorStrategy();

            return supervisorStrategy;
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RouterPoolActor"/> class.
        /// </summary>
        /// <param name="supervisorStrategy">The supervisor strategy.</param>
        /// <exception cref="ActorInitializationException"></exception>
        public RouterPoolActor(SupervisorStrategy supervisorStrategy)
        {
            _supervisorStrategy = supervisorStrategy;

            var pool = Cell.RouterConfig as Pool;

            if (pool != null)
            {
                Pool = pool;
            }
            else
            {
                throw new ActorInitializationException($"RouterPoolActor can only be used with Pool, not {Cell.RouterConfig.GetType()}");
            }
        }
        public void TestProbeChildActorWithSupervisorStrategy_PropsSupervisorStrategy__ReturnsSameResultOnEveryCall()
        {
            //arrange
            AllForOneStrategy exptected = new AllForOneStrategy(
                TestHelper.GenerateNumber(),
                TestHelper.GenerateNumber(),
                exception => TestHelper.Generate <Directive>());
            TestProbeChildActor sut = CreateTestProbeChildActorWithSupervisorStrategy(exptected).UnderlyingActor;

            //act
            SupervisorStrategy result = sut.PropsSupervisorStrategy;

            //assert
            result.Should().BeSameAs(exptected);
        }
 public BackoffSupervisor(
     Props childProps,
     string childName,
     TimeSpan minBackoff,
     TimeSpan maxBackoff,
     IBackoffReset reset,
     double randomFactor,
     SupervisorStrategy strategy,
     object replyWhileStopped             = null,
     Func <object, bool> finalStopMessage = null) : base(childProps, childName, reset, replyWhileStopped, finalStopMessage)
 {
     _minBackoff   = minBackoff;
     _maxBackoff   = maxBackoff;
     _randomFactor = randomFactor;
     _strategy     = strategy;
 }
Example #5
0
        public ClusterRouterPoolActor(SupervisorStrategy supervisorStrategy, ClusterRouterPoolSettings settings) : base(settings)
        {
            _supervisorStrategy = supervisorStrategy;
            Settings            = settings;

            var pool = Cell.RouterConfig as Pool;

            if (pool != null)
            {
                Pool = pool;
            }
            else
            {
                throw new ActorInitializationException("RouterPoolActor can only be used with Pool, not " +
                                                       Cell.RouterConfig.GetType());
            }
        }
Example #6
0
        public TestBase() : base(AkkaConfig.Config)
        {
            SupervisorStrategy = new AllForOneStrategy(
                TestHelper.GenerateNumber(),
                TestHelper.GenerateNumber(),
                exception => TestHelper.Generate <Directive>());

            ActorWithNonDefaultSupervisorStrategy =
                ActorOfAsTestActorRef <DummyActor1>(
                    Props.Create(() => new DummyActor1(SupervisorStrategy)))
                .UnderlyingActor;

            ActorWithDefaultSupervisorStrategy =
                ActorOfAsTestActorRef <DummyActor2>(
                    Props.Create(() => new DummyActor2()))
                .UnderlyingActor;
        }
Example #7
0
            public ParentWithFailingChildActor(Mailbox failingChildMailbox, IEnumerable <Mailbox> siblingMailboxes, SupervisorStrategy supervisorStrategy = null)
            {
                _supervisorStrategy = supervisorStrategy;
                var failingChildProps = new DelegateActorCreationProperties(() => AnonymousActor.Create <object>(_ => { throw new Exception(); }))
                {
                    MailboxCreator = () => failingChildMailbox
                };
                Func <Mailbox, ActorCreationProperties> createSibling = m => new DelegateActorCreationProperties(() => new NoopActor())
                {
                    MailboxCreator = () => m
                };

                var failingChild = CreateActor(failingChildProps, "FailingChild");

                siblingMailboxes.ForEach((m, i) => CreateActor(createSibling(m), "Sibling" + i));
                ReceiveAnyAndForward(failingChild);
            }
        public void UnitTestFramework_ResolvedSupervisorStrategiesAreStored()
        {
            //arrange
            SupervisorStrategy parentSupervisorStrategy = new AllForOneStrategy(exception => Directive.Restart);
            SupervisorStrategy childSupervisorStrategy  = new OneForOneStrategy(exception => Directive.Restart);
            UnitTestFramework <ParentActorWithSupervisorStratery> sut = UnitTestFrameworkSettings
                                                                        .Empty
                                                                        .CreateFramework <ParentActorWithSupervisorStratery>(this,
                                                                                                                             Props.Create(() =>
                                                                                                                                          new ParentActorWithSupervisorStratery(parentSupervisorStrategy, childSupervisorStrategy)), 2);

            //act
            SupervisorStrategy result = sut.ResolvedSupervisorStrategy("ChildWithParentSupervisorStrategy");

            //assert
            result.Should().BeSameAs(parentSupervisorStrategy);
        }
        public void ResolvedTestProbeStoreWithMultipleActorsResolved_FindResolvedSupervisorStrategyWithNameThatHasBeenResolvedWithoutASupervisorStrategy_ReturnsNull()
        {
            //arrange
            ResolvedTestProbeStore sut = CreateResolvedTestProbeStore();

            (ActorPath path1, Type type1, TestProbe probe1, SupervisorStrategy supervisorStrategy1, _) = CreateChildVariables();
            (ActorPath path2, Type type2, TestProbe probe2, _, string name2) = CreateChildVariables();
            (ActorPath path3, Type type3, TestProbe probe3, SupervisorStrategy supervisorStrategy3, _) = CreateChildVariables();
            sut.ResolveProbe(path1, type1, probe1, supervisorStrategy1);
            sut.ResolveProbe(path2, type2, probe2, null);
            sut.ResolveProbe(path3, type3, probe3, supervisorStrategy3);

            //act
            SupervisorStrategy result = sut.FindResolvedSupervisorStrategy(TestActor, name2);

            //assert
            result.Should().BeNull();
        }
Example #10
0
        public static Behavior <T> Supervise <T, TError>(this Behavior <T> behavior, SupervisorStrategy strategy)
            where T : class
            where TError : Exception
        {
            switch (strategy)
            {
            case Resume resume: return(behavior.Intercept(new ResumeSupervisor <T, TError>(resume, behavior)));

            case Restart restart: return(behavior.Intercept(new RestartSupervisor <T, TError>(restart, behavior)));

            case Stop stop: return(behavior.Intercept(new StopSupervisor <T, TError>(stop, behavior)));

            case Backoff backoff: return(behavior.Intercept(new BackoffSupervisor <T, TError>(backoff, behavior)));

            default:
                Raises.NotSupported($"Supervisor strategy [{strategy?.GetType()}] is not supported. Supported strategies are: Restart, Resume, Stop, Backoff.");
                return(default);
            }
        }
        public void UnitTestFramework_TheParentsSupervisorStrategyIsReturnedWhenTheChildDoesNotHaveOneSetInItsProps()
        {
            //arrange
            SupervisorStrategy parentSupervisorStrategy = new AllForOneStrategy(exception => Directive.Restart);
            SupervisorStrategy childSupervisorStrategy  = new OneForOneStrategy(exception => Directive.Restart);

            UnitTestFramework <ParentActorWithSupervisorStratery> sut = UnitTestFrameworkSettings
                                                                        .Empty
                                                                        .CreateFramework <ParentActorWithSupervisorStratery>(
                this,
                Props.Create(() => new ParentActorWithSupervisorStratery(parentSupervisorStrategy, childSupervisorStrategy)),
                2);

            //act
            SupervisorStrategy result = sut.ResolvedSupervisorStrategy("ChildWithChildSupervisorStrategy");

            //assert
            result.Should().BeSameAs(childSupervisorStrategy);
        }
Example #12
0
        /// <inheritdoc />
        public override RouterConfig WithFallback(RouterConfig routerConfig)
        {
            routerConfig = base.WithFallback(routerConfig);

            if (!SupervisorStrategy.Equals(DefaultSupervisorStrategy))
            {
                return(this);
            }

            if (routerConfig is FromConfig || routerConfig is NoRouter)
            {
                return(this); // NoRouter is the default, hence “neutral”
            }
            if (routerConfig is AdaptiveLoadBalancingPool adaptiveLoadBalancingPool)
            {
                return(adaptiveLoadBalancingPool.SupervisorStrategy.Equals(DefaultSupervisorStrategy)
                    ? this
                    : WithSupervisorStrategy(adaptiveLoadBalancingPool.SupervisorStrategy));
            }

            throw new ArgumentException(nameof(routerConfig), $"Expected AdaptiveLoadBalancingPool, got {routerConfig}");
        }
Example #13
0
        private RouterConfig OverrideUnsetConfig(RouterConfig other)
        {
            if (other is NoRouter)
            {
                return(this);
            }
            else
            {
                var pool = other as Pool;
                if (pool != null)
                {
                    RoundRobinPool wssConf;

                    if (SupervisorStrategy != null &&
                        SupervisorStrategy.Equals(Pool.DefaultSupervisorStrategy) &&
                        !(pool.SupervisorStrategy.Equals(Pool.DefaultSupervisorStrategy)))
                    {
                        wssConf = this.WithSupervisorStrategy(pool.SupervisorStrategy);
                    }
                    else
                    {
                        wssConf = this;
                    }

                    if (wssConf.Resizer == null && pool.Resizer != null)
                    {
                        return(wssConf.WithResizer(pool.Resizer));
                    }

                    return(wssConf);
                }
                else
                {
                    return(this);
                }
            }
        }
Example #14
0
 /// <summary>
 /// </summary>
 /// <param name="nrOfInstances">The nr of instances.</param>
 /// <param name="resizer">The resizer.</param>
 /// <param name="supervisorStrategy">The supervisor strategy.</param>
 /// <param name="routerDispatcher">The router dispatcher.</param>
 /// <param name="usePoolDispatcher">if set to <c>true</c> [use pool dispatcher].</param>
 public SmallestMailboxPool(int nrOfInstances, Resizer resizer, SupervisorStrategy supervisorStrategy,
                            string routerDispatcher, bool usePoolDispatcher = false)
     : base(nrOfInstances, resizer, supervisorStrategy, routerDispatcher, usePoolDispatcher)
 {
 }
 public override Pool WithSupervisorStrategy(SupervisorStrategy strategy)
 {
     return(new ScatterGatherFirstCompletedPool(NrOfInstances, Resizer, strategy, RouterDispatcher, _within, UsePoolDispatcher));
 }
Example #16
0
 /// <summary>
 /// Creates a new <see cref="RoundRobinPool"/> router with a given <see cref="SupervisorStrategy"/>.
 /// <note>
 /// This method is immutable and returns a new instance of the router.
 /// </note>
 /// </summary>
 /// <param name="strategy">The <see cref="SupervisorStrategy"/> used to configure the new router.</param>
 /// <returns>A new router with the provided <paramref name="strategy"/>.</returns>
 public RoundRobinPool WithSupervisorStrategy(SupervisorStrategy strategy)
 {
     return(new RoundRobinPool(NrOfInstances, Resizer, strategy, RouterDispatcher, UsePoolDispatcher));
 }
Example #17
0
 /// <summary>
 /// Creates a new <see cref="SmallestMailboxPool" /> router with a given <see cref="SupervisorStrategy" />.
 ///
 /// <note>
 /// This method is immutable and returns a new instance of the router.
 /// </note>
 /// </summary>
 /// <param name="strategy">The <see cref="SupervisorStrategy" /> used to configure the new router.</param>
 /// <returns>A new router with the provided <paramref name="strategy" />.</returns>
 public SmallestMailboxPool WithSupervisorStrategy(SupervisorStrategy strategy)
 {
     return(new SmallestMailboxPool(NrOfInstances, Resizer, strategy, RouterDispatcher, UsePoolDispatcher));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RouterPoolActor"/> class.
 /// </summary>
 /// <param name="supervisorStrategy">The supervisor strategy.</param>
 public RouterPoolActor(SupervisorStrategy supervisorStrategy)
 {
     _supervisorStrategy = supervisorStrategy;
 }
Example #19
0
        public TestBase() : base(AkkaConfig.Config)
        {
            Func <Type> generateType = TestUtils.RandomTypeGenerator();

            // Create mocks
            SutCreatorMock                       = new Mock <ISutCreator>();
            ChildTellerMock                      = new Mock <ITellChildWaiter>();
            ChildWaiterMock                      = new Mock <IChildWaiter>();
            DependencyResolverAdderMock          = new Mock <IDependencyResolverAdder>();
            TestProbeDependencyResolverAdderMock = new Mock <ITestProbeDependencyResolverAdder>();
            ResolvedTestProbeStoreMock           = new Mock <IResolvedTestProbeStore>();
            TestProbeActorCreatorMock            = new Mock <ITestProbeActorCreator>();
            TestProbeCreatorMock                 = new Mock <ITestProbeCreator>();
            TestProbeHandlersMapperMock          = new Mock <ITestProbeHandlersMapper>();
            TestProbeActorMock                   = new Mock <ITestProbeActor>();
            SutSupervisorStrategyGetterMock      = new Mock <ISutSupervisorStrategyGetter>();

            // Create objects passed into sut constructor
            SutCreator                       = SutCreatorMock.Object;
            ChildTeller                      = ChildTellerMock.Object;
            ChildWaiter                      = ChildWaiterMock.Object;
            DependencyResolverAdder          = DependencyResolverAdderMock.Object;
            TestProbeDependencyResolverAdder = TestProbeDependencyResolverAdderMock.Object;
            TestProbeCreator                 = TestProbeCreatorMock.Object;
            ResolvedTestProbeStore           = ResolvedTestProbeStoreMock.Object;
            TestProbeActorCreator            = TestProbeActorCreatorMock.Object;
            TestProbeHandlersMapper          = TestProbeHandlersMapperMock.Object;
            SutSupervisorStrategyGetter      = SutSupervisorStrategyGetterMock.Object;
            Handlers = ImmutableDictionary <(Type, Type), Func <object, object> >
                       .Empty
                       .Add((generateType(), generateType()), message => TestUtils.Create <object>());

            Props = Props.Create <DummyActor>();
            PropsWithSupervisorStrategy = Props
                                          .Create <DummyActor>()
                                          .WithSupervisorStrategy(new AllForOneStrategy(
                                                                      TestUtils.Create <int>(),
                                                                      TestUtils.Create <int>(),
                                                                      exception => TestUtils.Create <Directive>()));
            ExpectedChildCount = TestUtils.Create <int>();

            // Create objects passed into sut methods
            Message   = TestUtils.Create <object>();
            ChildName = TestUtils.Create <string>();
            ChildNameWithoutSupervisor = TestUtils.Create <string>();
            Sender = new Mock <IActorRef>().Object;

            // Create objects returned by mocks
            MappedHandlers = ImmutableDictionary <Type, ImmutableDictionary <Type, Func <object, object> > >
                             .Empty
                             .Add(generateType(), ImmutableDictionary <Type, Func <object, object> >
                                  .Empty
                                  .Add(generateType(), mess => TestUtils.Create <object>()));

            Supervisor                 = CreateTestProbe();
            SutActor                   = ActorOfAsTestActorRef <DummyActor>();
            ResolvedType               = generateType();
            ResolvedTestProbe          = CreateTestProbe();
            ResolvedSupervisorStrategy = new AllForOneStrategy(
                TestUtils.Create <int>(),
                TestUtils.Create <int>(),
                exception => TestUtils.Create <Directive>());
            SutSupervisorStrategy = new OneForOneStrategy(
                TestUtils.Create <int>(),
                TestUtils.Create <int>(),
                exception => TestUtils.Create <Directive>());

            // Set up mocks
            TestProbeCreatorMock
            .SetupSequence(creator => creator.Create(this))
            .Returns(Supervisor)
            .Returns(CreateTestProbe());

            SutCreatorMock
            .Setup(creator => creator.Create <DummyActor>(
                       ChildWaiterMock.Object,
                       this,
                       Props,
                       ExpectedChildCount,
                       Supervisor))
            .Returns(() => SutActor);

            ResolvedTestProbeStoreMock
            .Setup(store => store.FindResolvedType(SutActor, ChildName))
            .Returns(() => ResolvedType);
            ResolvedTestProbeStoreMock
            .Setup(store => store.FindResolvedTestProbe(SutActor, ChildName))
            .Returns(() => ResolvedTestProbe);
            ResolvedTestProbeStoreMock
            .Setup(store => store.FindResolvedSupervisorStrategy(SutActor, ChildName))
            .Returns(() => ResolvedSupervisorStrategy);
            ResolvedTestProbeStoreMock
            .Setup(store => store.FindResolvedSupervisorStrategy(SutActor, ChildNameWithoutSupervisor))
            .Returns(() => null);

            TestProbeHandlersMapperMock
            .Setup(mapper => mapper.Map(Handlers))
            .Returns(() => MappedHandlers);

            SutSupervisorStrategyGetterMock
            .Setup(getter => getter.Get(SutActor.UnderlyingActor))
            .Returns(() => SutSupervisorStrategy);
        }
Example #20
0
 /// <summary>
 /// Returns a new instance of the <see cref="Pool"/> router with a new <see cref="SupervisorStrategy"/>.
 ///
 /// NOTE: this method is immutable and returns a new instance of the <see cref="Pool"/>.
 /// </summary>
 public abstract Pool WithSupervisorStrategy(SupervisorStrategy strategy);
Example #21
0
        public TestBase() : base(AkkaConfig.Config)
        {
            Func <Type> generateType = TestHelper.GetRandomTypeGenerator();

            // Create mocks
            SutCreatorMock                       = new Mock <ISutCreator>();
            TellWaiterMock                       = new Mock <ITellWaiter>();
            ChildWaiterMock                      = new Mock <IWaiter>();
            ExceptionWaiterMock                  = new Mock <IWaiter>();
            DependencyResolverAdderMock          = new Mock <IDependencyResolverAdder>();
            TestProbeDependencyResolverAdderMock = new Mock <ITestProbeDependencyResolverAdder>();
            ResolvedTestProbeStoreMock           = new Mock <IResolvedTestProbeStore>();
            TestProbeChildActorCreatorMock       = new Mock <ITestProbeChildActorCreator>();
            TestProbeCreatorMock                 = new Mock <ITestProbeCreator>();
            TestProbeHandlersMapperMock          = new Mock <ITestProbeChildHandlersMapper>();
            TestProbeChildActorMock              = new Mock <ITestProbeChildActor>();
            SutSupervisorStrategyGetterMock      = new Mock <ISutSupervisorStrategyGetter>();
            TestProbeParentActorCreatorMock      = new Mock <ITestProbeParentActorCreator>();
            TestProbeParentActorMock             = new Mock <ITestProbeParentActor>();
            DelayerMock = new Mock <IDelayer>();

            // Create objects passed into sut constructor
            SutCreator                       = SutCreatorMock.Object;
            TellWaiter                       = TellWaiterMock.Object;
            ChildWaiter                      = ChildWaiterMock.Object;
            ExceptionWaiter                  = ChildWaiterMock.Object;
            DependencyResolverAdder          = DependencyResolverAdderMock.Object;
            TestProbeDependencyResolverAdder = TestProbeDependencyResolverAdderMock.Object;
            TestProbeCreator                 = TestProbeCreatorMock.Object;
            ResolvedTestProbeStore           = ResolvedTestProbeStoreMock.Object;
            TestProbeChildActorCreator       = TestProbeChildActorCreatorMock.Object;
            TestProbeHandlersMapper          = TestProbeHandlersMapperMock.Object;
            SutSupervisorStrategyGetter      = SutSupervisorStrategyGetterMock.Object;
            TestProbeParentActorCreator      = TestProbeParentActorCreatorMock.Object;
            Delayer        = DelayerMock.Object;
            ParentHandlers = ImmutableDictionary <Type, Func <object, object> >
                             .Empty
                             .Add((generateType()), message => TestHelper.Generate <object>());

            ChildHandlers = ImmutableDictionary <(Type, Type), Func <object, object> >
                            .Empty
                            .Add((generateType(), generateType()), message => TestHelper.Generate <object>());

            Decider = exception => TestHelper.GenerateEnum <Directive>();
            Props   = Props.Create <DummyActor>();
            PropsWithSupervisorStrategy = Props
                                          .Create <DummyActor>()
                                          .WithSupervisorStrategy(new AllForOneStrategy(
                                                                      TestHelper.GenerateNumber(),
                                                                      TestHelper.GenerateNumber(),
                                                                      exception => TestHelper.Generate <Directive>()));
            ExpectedChildCount     = TestHelper.GenerateNumber();
            ExpectedExceptionCount = TestHelper.GenerateNumber();

            // Create objects passed into sut methods
            Message   = TestHelper.Generate <object>();
            ChildName = TestHelper.GenerateString();
            ChildNameWithoutSupervisor = TestHelper.GenerateString();
            Sender        = new Mock <IActorRef>().Object;
            DelayDuration = TestHelper.Generate <TimeSpan>();

            // Create objects returned by mocks
            MappedChildHandlers = ImmutableDictionary <Type, ImmutableDictionary <Type, Func <object, object> > >
                                  .Empty
                                  .Add(generateType(), ImmutableDictionary <Type, Func <object, object> >
                                       .Empty
                                       .Add(generateType(), mess => TestHelper.Generate <object>()));

            SutActor                   = ActorOfAsTestActorRef <DummyActor>();
            ResolvedType               = generateType();
            ResolvedTestProbe          = CreateTestProbe();
            ResolvedSupervisorStrategy = new AllForOneStrategy(
                TestHelper.GenerateNumber(),
                TestHelper.GenerateNumber(),
                exception => TestHelper.Generate <Directive>());
            SutSupervisorStrategy = new OneForOneStrategy(
                TestHelper.GenerateNumber(),
                TestHelper.GenerateNumber(),
                exception => TestHelper.Generate <Directive>());
            TestProbeParentActor                    = TestProbeParentActorMock.Object;
            TestProbeParentActorTestProbe           = CreateTestProbe();
            TestProbeParentActorRef                 = TestProbeParentActorTestProbe.Ref;
            TestProbeParentActorUnhandledExceptions = TestHelper.GenerateMany <Exception>(() => TestHelper.GenerateException());

            // Set up mocks
            TestProbeParentActorMock
            .SetupGet(actor => actor.Ref)
            .Returns(TestProbeParentActorRef);
            TestProbeParentActorMock
            .SetupGet(actor => actor.TestProbe)
            .Returns(TestProbeParentActorTestProbe);
            TestProbeParentActorMock
            .SetupGet(actor => actor.UnhandledExceptions)
            .Returns(TestProbeParentActorUnhandledExceptions);

            TestProbeParentActorCreatorMock
            .SetupSequence(creator => creator.Create(TestProbeCreator, ExceptionWaiter, this, Decider, ParentHandlers))
            .Returns(TestProbeParentActor)
            .Returns(Mock.Of <ITestProbeParentActor>());

            SutCreatorMock
            .Setup(creator => creator.Create <DummyActor>(
                       ChildWaiterMock.Object,
                       this,
                       Props,
                       ExpectedChildCount,
                       TestProbeParentActorRef))
            .Returns(() => SutActor);

            ResolvedTestProbeStoreMock
            .Setup(store => store.FindResolvedType(SutActor, ChildName))
            .Returns(() => ResolvedType);
            ResolvedTestProbeStoreMock
            .Setup(store => store.FindResolvedTestProbe(SutActor, ChildName))
            .Returns(() => ResolvedTestProbe);
            ResolvedTestProbeStoreMock
            .Setup(store => store.FindResolvedSupervisorStrategy(SutActor, ChildName))
            .Returns(() => ResolvedSupervisorStrategy);
            ResolvedTestProbeStoreMock
            .Setup(store => store.FindResolvedSupervisorStrategy(SutActor, ChildNameWithoutSupervisor))
            .Returns(() => null);

            TestProbeHandlersMapperMock
            .Setup(mapper => mapper.Map(ChildHandlers))
            .Returns(() => MappedChildHandlers);

            SutSupervisorStrategyGetterMock
            .Setup(getter => getter.Get(SutActor.UnderlyingActor))
            .Returns(() => SutSupervisorStrategy);
        }
Example #22
0
        /// <summary>

        /// </summary>
        /// <param name="nrOfInstances">The nr of instances.</param>
        /// <param name="resizer">The resizer.</param>
        /// <param name="supervisorStrategy">The supervisor strategy.</param>
        /// <param name="routerDispatcher">The router dispatcher.</param>
        /// <param name="usePoolDispatcher">if set to <c>true</c> [use pool dispatcher].</param>
        public RoundRobinPool(int nrOfInstances, Resizer resizer, SupervisorStrategy supervisorStrategy,
                              string routerDispatcher, bool usePoolDispatcher = false)
            : base(nrOfInstances, resizer, supervisorStrategy, routerDispatcher, usePoolDispatcher)
        {
        }
Example #23
0
 /// <summary>
 /// Creates a new <see cref="TailChoppingPool"/> router with a given <see cref="SupervisorStrategy"/>.
 ///
 /// <note>
 /// This method is immutable and returns a new instance of the router.
 /// </note>
 /// </summary>
 /// <param name="strategy">The <see cref="SupervisorStrategy"/> used to configure the new router.</param>
 /// <returns>A new router with the provided <paramref name="strategy"/>.</returns>
 public TailChoppingPool WithSupervisorStrategy(SupervisorStrategy strategy)
 {
     return(new TailChoppingPool(NrOfInstances, Resizer, strategy, RouterDispatcher, Within, Interval, UsePoolDispatcher));
 }
Example #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TailChoppingPool"/> class.
 /// </summary>
 /// <param name="nrOfInstances">The initial number of routees in the pool.</param>
 /// <param name="resizer">The resizer to use when dynamically allocating routees to the pool.</param>
 /// <param name="supervisorStrategy">The strategy to use when supervising the pool.</param>
 /// <param name="routerDispatcher">The dispatcher to use when passing messages to the routees.</param>
 /// <param name="within">The amount of time to wait for a response.</param>
 /// <param name="interval">The interval to wait before sending to the next routee.</param>
 /// <param name="usePoolDispatcher"><c>true</c> to use the pool dispatcher; otherwise <c>false</c>.</param>
 public TailChoppingPool(int nrOfInstances, Resizer resizer, SupervisorStrategy supervisorStrategy, string routerDispatcher, TimeSpan within, TimeSpan interval, bool usePoolDispatcher = false)
     : base(nrOfInstances, resizer, supervisorStrategy, routerDispatcher, usePoolDispatcher)
 {
     Within   = within;
     Interval = interval;
 }
Example #25
0
 public ResizablePoolActor(SupervisorStrategy supervisorStrategy) : base(supervisorStrategy)
 {
 }
Example #26
0
 /// <summary>
 /// Setting the supervisor strategy to be used for the "head" Router actor
 /// </summary>
 /// <param name="strategy">TBD</param>
 /// <returns>TBD</returns>
 public FromConfig WithSupervisorStrategy(SupervisorStrategy strategy)
 {
     return(new FromConfig(Resizer, strategy, RouterDispatcher));
 }
Example #27
0
 internal TestActorRef <TestProbeChildActor> CreateTestProbeChildActorWithSupervisorStrategy(SupervisorStrategy supervisorStrategy) =>
 ActorOfAsTestActorRef <TestProbeChildActor>(Props
                                             .Create(() => new TestProbeChildActor(TestProbeCreator, this, Handlers))
                                             .WithSupervisorStrategy(supervisorStrategy));
Example #28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FromConfig" /> class.
 /// </summary>
 /// <param name="resizer">TBD</param>
 /// <param name="supervisorStrategy">TBD</param>
 /// <param name="routerDispatcher">TBD</param>
 public FromConfig(Resizer resizer, SupervisorStrategy supervisorStrategy, string routerDispatcher)
     : base(0, resizer, supervisorStrategy, routerDispatcher, false)
 {
 }
Example #29
0
 /// <summary>
 /// Creates a new <see cref="BroadcastPool"/> router with a given <see cref="SupervisorStrategy"/>.
 /// <note>
 /// This method is immutable and returns a new instance of the router.
 /// </note>
 /// </summary>
 /// <param name="strategy">The <see cref="SupervisorStrategy"/> used to configure the new router.</param>
 /// <returns>A new router with the provided <paramref name="strategy" />.</returns>
 public BroadcastPool WithSupervisorStrategy(SupervisorStrategy strategy)
 {
     return(new BroadcastPool(NrOfInstances, Resizer, strategy, RouterDispatcher, UsePoolDispatcher));
 }
Example #30
0
 /// <summary>
 /// </summary>
 /// <param name="nrOfInstances">The nr of instances.</param>
 /// <param name="resizer">The resizer.</param>
 /// <param name="supervisorStrategy">The supervisor strategy.</param>
 /// <param name="routerDispatcher">The router dispatcher.</param>
 /// <param name="usePoolDispatcher">if set to <c>true</c> [use pool dispatcher].</param>
 public ScatterGatherFirstCompletedPool(int nrOfInstances, Resizer resizer, SupervisorStrategy supervisorStrategy,
                                        string routerDispatcher, TimeSpan within, bool usePoolDispatcher = false)
     : base(nrOfInstances, resizer, supervisorStrategy, routerDispatcher, usePoolDispatcher)
 {
     _within = within;
 }
Example #31
0
 /// <summary>
 /// Spawns an actor as a child of this test actor with an auto-generated name, and returns the child's ActorRef.
 /// </summary>
 /// <param name="props">Child actor props</param>
 /// <param name="supervisorStrategy">Supervisor strategy for the child actor</param>
 /// <returns></returns>
 public IActorRef ChildActorOf(Props props, SupervisorStrategy supervisorStrategy)
 {
     TestActor.Tell(new TestActor.Spawn(props, Option <string> .None, supervisorStrategy));
     return(ExpectMsg <IActorRef>());
 }