コード例 #1
0
ファイル: ActorGrain.cs プロジェクト: gansuranga/Orleankka
        /// <summary>
        /// Provided only for unit-testing purposes
        /// </summary>
        protected ActorGrain(string id = null, IActorRuntime runtime = null)
        {
            var @interface = ActorGrainImplementation.InterfaceOf(GetType());

            Path    = ActorPath.For(@interface, id ?? Guid.NewGuid().ToString("N"));
            Runtime = runtime;
        }
コード例 #2
0
ファイル: ActorGrain.cs プロジェクト: stantoxt/Orleankka
        /// <summary>
        /// Provided only for unit-testing purposes
        /// </summary>
        protected ActorGrain(string id = null, IActorRuntime runtime = null)
        {
            var @interface = InterfaceOf(GetType());

            Path         = ActorPath.For(@interface, id ?? Guid.NewGuid().ToString("N"));
            System       = runtime?.System;
            this.runtime = runtime;
        }
コード例 #3
0
ファイル: ActorGrain.cs プロジェクト: nuspect/Orleankka
        /// <summary>
        /// Run-once initialization routine invoked right after actor grain construction and just before activate
        /// TODO: this is not ideal since IActorRuntime cannot be created here. Still, need support for IActivationFilter from Orleans
        /// </summary>
        internal virtual void Initialize(IServiceProvider services, string id)
        {
            var clusterSystem = services.GetRequiredService <ClusterActorSystem>();

            System = clusterSystem;

            var implementation = clusterSystem.ImplementationOf(GetType());

            middleware = implementation.Middleware;

            Path = ActorPath.For(implementation.Interface, id);
        }
コード例 #4
0
ファイル: ActorGrain.cs プロジェクト: gansuranga/Orleankka
        public override Task OnActivateAsync()
        {
            var system = ServiceProvider.GetRequiredService <ClusterActorSystem>();

            var implementation = system.ImplementationOf(GetType());

            middleware = implementation.Middleware;

            Path    = ActorPath.For(implementation.Interface, this.GetPrimaryKeyString());
            Runtime = new ActorRuntime(system, this);

            return(middleware.Receive(this, Activate.Message, Receive));
        }
コード例 #5
0
ファイル: ActorSystem.cs プロジェクト: stantoxt/Orleankka
 /// <summary>
 /// Acquires the typed actor reference for the given id and type of the worker actor.
 /// The type could be either an interface or implementation class.
 /// </summary>
 /// <typeparam name="TActor">The type of the actor</typeparam>
 /// <param name="system">The reference to actor system</param>
 public static ActorRef <TActor> TypedWorkerOf <TActor>(this IActorSystem system) where TActor : IActorGrain, IGrainWithStringKey
 {
     return(new ActorRef <TActor>(system.ActorOf(ActorPath.For(typeof(TActor), "#"))));
 }
コード例 #6
0
ファイル: ActorSystem.cs プロジェクト: stantoxt/Orleankka
 /// <summary>
 /// Acquires the actor reference for the given worker type.
 /// </summary>
 /// <param name="system">The reference to actor system</param>
 /// <param name="interface">The worker interface</param>
 /// <returns>An actor reference</returns>
 public static ActorRef WorkerOf(this IActorSystem system, Type @interface)
 {
     return(system.ActorOf(ActorPath.For(@interface, "#")));
 }
コード例 #7
0
ファイル: ActorSystem.cs プロジェクト: stantoxt/Orleankka
 /// <summary>
 /// Acquires the actor reference for the given actor type and id.
 /// </summary>
 /// <param name="system">The reference to actor system</param>
 /// <param name="interface">The actor interface</param>
 /// <param name="id">The actor id</param>
 /// <returns>An actor reference</returns>
 public static ActorRef ActorOf(this IActorSystem system, Type @interface, string id)
 {
     return(system.ActorOf(ActorPath.For(@interface, id)));
 }
コード例 #8
0
 /// <summary>
 /// Acquires the typed actor reference for the given id and type of the actor.
 /// The type could be either an interface or implementation class.
 /// </summary>
 /// <typeparam name="TActor">The type of the actor</typeparam>
 /// <param name="system">The reference to actor system</param>
 /// <param name="id">The id</param>
 public static ActorRef <TActor> TypedActorOf <TActor>(this IActorSystem system, string id) where TActor : IActorGrain
 {
     return(new ActorRef <TActor>(system.ActorOf(ActorPath.For(typeof(TActor), id))));
 }