Example #1
0
        public async Task <ActorKey> GetOrCreate(string actorName)
        {
            await _initializedTask.Task;

            Log.Debug("GetOrCreate name:" + actorName);

            ActorRemoteInfo actorInfo;

            if (_actorsByName.TryGetValue(actorName, out actorInfo))
            {
                Log.Debug("GetOrCreate->Resolved {0} from cache", actorInfo);
                return(actorInfo.Key);
            }
            else
            {
                NodeRemoteInfo targetNode = _distributionFunc(_node.ClusterView);
                Log.Debug("GetOrCreate->Creating Actor<Name:{0}> on NodeId:{1}", actorName, targetNode.NodeId);
                if (targetNode.NodeId != _node.Id)
                {
                    _isisGroup.OrderedSend(CreateActorOperationId, actorName, targetNode.NodeId);
                }
                else
                {
                    Actor newActor = _node.Repository.Create(_node, actorName, _primaryNetContractId);
                    _isisGroup.OrderedSend(ActorCreatedOperationId, actorName, _node.Id, newActor.LocalId);
                }


                var             tcs   = new TaskCompletionSource <ActorRemoteInfo>();
                ActorRemoteInfo actor = null;
                _pendingActorsByName.TryAdd(actorName, tcs);

                actor = await tcs.Task;

                return(actor.Key);
            }
        }
 public Future <TNetPeer> ConnectToServer(string serverEndPoint)
 {
     return(ConnectToServer(NodeRemoteInfo.ParseIPEndPoint(serverEndPoint)));
 }