public ActorMetadata(string name, ActorMetadata parent = null)
        {
            Name = name;
            var parentPath = parent != null ? parent.Path : "/user";

            Path = $"{parentPath}/{Name}";
        }
예제 #2
0
        public static async Task <IActorRef> CreateActorIfNotExistsAsync(this ActorSystem actorSystem,
                                                                         ActorMetadata actorPath, Props creationProps)
        {
            IActorRef actor = null;

            try
            {
                actor = await actorSystem.ActorSelection(actorPath.Path)
                        .ResolveOne(TimeSpan.FromSeconds(1));
            }
            catch (ActorNotFoundException)
            {
                actor = actorSystem.ActorOf(creationProps, actorPath.Name);
            }
            return(actor);
        }