Esempio n. 1
0
        public Process(string name, ActorSystem actorSystem, IActor actor, ActorOptions options)
            : base(-1, -1)
        {
            _name = name;

            _actor       = actor;
            _actorSystem = actorSystem;

            _pid = new Pid(this);
            _ctx = new Context(this);

            _errorHandler = (options.ErrorHandler ?? actorSystem.Options.ErrorHandler) ?? DefaultErrorHandler.Instance;

            var requestTimeoutMSec = GetRequestTimeoutMSec(actorSystem, options);

            _requestTimeoutMSec = !requestTimeoutMSec.HasValue ? (int?)null :
                                  Math.Min(Math.Max(-1, requestTimeoutMSec.Value), Constants.MaxRequestTimeoutMSec);

            SetSequentialInvokeLimit(GetSequentialInvokeLimit(actorSystem, options));

            if (options.InitialContextData != null)
            {
                foreach (var kv in options.InitialContextData)
                {
                    _ctx.SetData(kv.Key, kv.Value);
                }
            }

            _processRegistery.TryAdd(_pid, this);
        }
Esempio n. 2
0
 internal bool TryGetInternal(string actorName, out Pid pid)
 {
     pid = null;
     if (_processRegistery.TryGetValue(actorName, out ProcessRegistery registry))
     {
         pid = registry.Process?.Pid;
         return(pid != null);
     }
     return(false);
 }
Esempio n. 3
0
        public bool TryGet(string actorName, out Pid pid)
        {
            pid       = null;
            actorName = actorName?.Trim();

            if (!String.IsNullOrEmpty(actorName))
            {
                return(TryGetInternal(actorName, out pid));
            }
            return(false);
        }
Esempio n. 4
0
        public bool TryGetRemote(Aid remoteAid, out Pid pid)
        {
            pid = null;
            if (remoteAid != null)
            {
                pid = remoteAid as Pid;
                if (pid?.Process != null)
                {
                    return(true);
                }

                return(TryGetInternal($"remote://{remoteAid.ActorSystem}/{remoteAid.Actor}", out pid));
            }
            return(false);
        }
Esempio n. 5
0
        public bool TryGetLocal(Aid localAid, out Pid pid)
        {
            pid = null;
            if (localAid != null)
            {
                pid = localAid as Pid;
                if (pid?.Process != null)
                {
                    return(true);
                }

                return(TryGetInternal(localAid.Actor, out pid));
            }
            return(false);
        }
Esempio n. 6
0
        public static bool TryGet(Aid aid, out Pid pid)
        {
            pid = null;
            if (aid != null)
            {
                pid = aid as Pid;
                if (pid?.Process != null)
                {
                    return(true);
                }

                if (TryGet(aid.ActorSystem, out ActorSystem actorSystem))
                {
                    return(actorSystem.TryGetInternal(aid.Actor, out pid) ||
                           actorSystem.TryGetInternal($"remote://{aid.ActorSystem}/{aid.Actor}", out pid));
                }
            }
            return(false);
        }
Esempio n. 7
0
 public void HandleProcessError(ActorSystem actorSystem, Pid pid, IMessage message, Exception error)
 {
     _processErrorHandler(actorSystem, pid, message, error);
 }
Esempio n. 8
0
 public void HandleProcessError(ActorSystem actorSystem, Pid pid, IMessage message, Exception error)
 {
 }
Esempio n. 9
0
 protected override void OnDispose(bool disposing)
 {
     _pid     = null;
     _process = null;
 }
Esempio n. 10
0
 internal Context(Process process)
 {
     _process = process;
     _pid     = _process.Pid;
 }