Example #1
0
        public void Register(string name, IActorInvoker invoker)
        {
            Requires.NotNullOrWhitespace(name, nameof(name));
            Requires.NotNull(invoker, nameof(invoker));

            invokers[name] = invoker;
        }
Example #2
0
        public void Register(string name, IActorInvoker invoker)
        {
            Requires.NotNullOrWhitespace(name, nameof(name));
            Requires.NotNull(invoker, nameof(invoker));

            if (invokers.ContainsKey(name))
            {
                throw new InvalidOperationException($"Invoker with name '{name}' is already registered");
            }

            invokers.Add(name, invoker);
        }
Example #3
0
        Task Activate()
        {
            var path = ActorPath.From(Actor.Name, IdentityOf(this));

            var system    = ServiceProvider.GetRequiredService <ClusterActorSystem>();
            var activator = ServiceProvider.GetRequiredService <IActorActivator>();

            var runtime = new ActorRuntime(system, this);

            instance = Actor.Activate(this, path, runtime, activator);
            invoker  = Actor.Invoker(system.Pipeline);

            return(invoker.OnActivate(instance));
        }
Example #4
0
        internal ActorType(Type actor, Type endpoint)
        {
            this.actor = actor;

            Name             = ActorTypeName.Of(actor);
            Sticky           = StickyAttribute.IsApplied(actor);
            keepAliveTimeout = Sticky ? TimeSpan.FromDays(365 * 10) : KeepAliveAttribute.Timeout(actor);
            Invoker          = InvocationPipeline.Instance.GetInvoker(actor, InvokerAttribute.From(actor));

            interleavePredicate = ReentrantAttribute.MayInterleavePredicate(actor);

            dispatcher = new Dispatcher(actor);
            dispatchers.Add(actor, dispatcher);

            Init(endpoint);
        }
Example #5
0
 protected ActorInvoker(IActorInvoker next = null)
 {
     Next = next ?? DefaultActorInvoker.Instance;
 }
Example #6
0
 public void Register(IActorInvoker invoker)
 {
     Requires.NotNull(invoker, nameof(invoker));
     DefaultInvoker = invoker;
 }
 /// <summary>
 /// Registers named actor invoker (interceptor). For this invoker to be used an actor need
 /// to specify its name via <see cref="InvokerAttribute"/> attribute.
 /// The invoker is inherited by all subclasses.
 /// </summary>
 /// <param name="name">The name of the invoker</param>
 /// <param name="invoker">The invoker.</param>
 public ClusterConfigurator ActorInvoker(string name, IActorInvoker invoker)
 {
     pipeline.Register(name, invoker);
     return(this);
 }
 /// <summary>
 /// Registers global actor invoker (interceptor). This invoker will be used for every actor
 /// which doesn't specify an individual invoker via <see cref="InvokerAttribute"/> attribute.
 /// </summary>
 /// <param name="global">The invoker.</param>
 public ClusterConfigurator ActorInvoker(IActorInvoker global)
 {
     pipeline.Register(global);
     return(this);
 }