Exemplo n.º 1
0
 internal bool IsLocal(ProcessId pid) =>
 pid.StartsWith(Root);
Exemplo n.º 2
0
 public Unit UnWatch(ProcessId pid) =>
 TellSystem(SystemMessage.UnWatch(pid), pid);
Exemplo n.º 3
0
 public Unit Tell(object message, Schedule schedule, ProcessId sender, Message.TagSpec tag) =>
 Tell(message, schedule, sender, "user", Message.Type.User, tag);
Exemplo n.º 4
0
 public UserMessage(object message, ProcessId sender, ProcessId replyTo)
 {
     Content = message;
     Sender  = sender;
     ReplyTo = replyTo;
 }
Exemplo n.º 5
0
 Unit DoSchedule(object message, Schedule schedule, ProcessId sender, Message.Type type, Message.TagSpec tag) =>
 transactionalIO
         ? DoScheduleNoIO(message, sender, schedule, type, tag)
         : ProcessOp.IO(() => DoScheduleNoIO(message, sender, schedule, type, tag));
Exemplo n.º 6
0
 public static string ClusterStatePubSubKey(ProcessId pid) =>
 ClusterKey(pid) + "-state-pubsub";
Exemplo n.º 7
0
 public static string ClusterScheduleNotifyKey(ProcessId pid) =>
 ClusterScheduleKey(pid) + "-notify";
Exemplo n.º 8
0
 public HashMap <string, ProcessId> GetChildren(ProcessId pid) =>
 GetDispatcher(pid).GetChildren();
Exemplo n.º 9
0
 public Unit Kill(ProcessId pid, bool maintainState) =>
 maintainState
         ? GetDispatcher(pid).Shutdown()
         : GetDispatcher(pid).Kill();
Exemplo n.º 10
0
 public Unit TellUserControl(ProcessId pid, UserControlMessage message) =>
 GetDispatcher(pid).TellUserControl(message, Self);
Exemplo n.º 11
0
 public Unit TellSystem(ProcessId pid, SystemMessage message) =>
 GetDispatcher(pid).TellSystem(message, Self);
Exemplo n.º 12
0
 public Unit Tell(ProcessId pid, object message, Schedule schedule, ProcessId sender) =>
 GetDispatcher(pid).Tell(message, schedule, sender.IsValid ? sender : Self, message is ActorRequest ? Message.TagSpec.UserAsk : Message.TagSpec.User);
Exemplo n.º 13
0
 public Unit Ask(ProcessId pid, object message, ProcessId sender) =>
 GetDispatcher(pid).Ask(message, sender.IsValid ? sender : Self);
Exemplo n.º 14
0
 internal bool IsDisp(ProcessId pid) =>
 pid.value.IsDisp;
Exemplo n.º 15
0
 public static string ClusterSystemInboxNotifyKey(ProcessId pid) =>
 ClusterInboxNotifyKey(pid, "system");
Exemplo n.º 16
0
        public static Option <UserControlMessage> PreProcessMessage <T>(ProcessId sender, ProcessId self, object message)
        {
            if (message == null)
            {
                var emsg = $"Message is null for tell (expected {typeof(T)})";
                tell(ActorContext.System(self).DeadLetters, DeadLetter.create(sender, self, emsg, message));
                return(None);
            }

            if (message is ActorRequest req)
            {
                if (!(req.Message is T) && !(req.Message is Message))
                {
                    var emsg = $"Invalid message type for ask (expected {typeof(T)})";
                    tell(ActorContext.System(self).DeadLetters, DeadLetter.create(sender, self, emsg, message));

                    ActorContext.System(self).Tell(
                        sender,
                        new ActorResponse(new Exception($"Invalid message type for ask (expected {typeof(T)})"),
                                          sender,
                                          self,
                                          req.RequestId,
                                          typeof(Exception).AssemblyQualifiedName,
                                          true
                                          ),
                        Schedule.Immediate,
                        self
                        );

                    return(None);
                }
                return(Optional((UserControlMessage)message));
            }

            return(new UserMessage(message, sender, sender));
        }
Exemplo n.º 17
0
 public static string ClusterMetaDataKey(ProcessId pid) =>
 ClusterKey(pid) + "-metadata";
Exemplo n.º 18
0
        public static Option <Tuple <RemoteMessageDTO, Message> > GetNextMessage(ICluster cluster, ProcessId self, string key)
        {
            if (cluster == null)
            {
                return(None);
            }
            Message          msg = null;
            RemoteMessageDTO dto = null;

            dto = null;
            do
            {
                dto = cluster.Peek <RemoteMessageDTO>(key);
                if (dto == null)
                {
                    // Queue is empty
                    return(None);
                }
                if (dto.Tag == 0 && dto.Type == 0)
                {
                    // Message is bad
                    cluster.Dequeue <RemoteMessageDTO>(key);
                    tell(ActorContext.System(self).DeadLetters, DeadLetter.create(dto.Sender, self, null, "Failed to deserialise message: ", dto));
                    if (cluster.QueueLength(key) == 0)
                    {
                        return(None);
                    }
                }
            }while (dto == null || dto.Tag == 0 || dto.Type == 0);

            try
            {
                msg           = MessageSerialiser.DeserialiseMsg(dto, self);
                msg.SessionId = dto.SessionId;
            }
            catch (Exception e)
            {
                // Message can't be deserialised
                cluster.Dequeue <RemoteMessageDTO>(key);
                tell(ActorContext.System(self).DeadLetters, DeadLetter.create(dto.Sender, self, e, "Failed to deserialise message: ", msg));
                return(None);
            }

            return(Some(Tuple(dto, msg)));
        }
Exemplo n.º 19
0
 public static string ClusterScheduleKey(ProcessId pid) =>
 $"/__schedule{ClusterKey(pid)}-user-schedule";
Exemplo n.º 20
0
 public static string ClusterKey(ProcessId pid) =>
 pid.Path;
Exemplo n.º 21
0
 internal static RemoteMessageDTO CreateResponse(ActorResponse res, ProcessId to, ProcessId sender, Option <SessionId> sessionId) =>
 new RemoteMessageDTO
 {
     Type      = (int)Message.Type.User,
     Tag       = (int)Message.TagSpec.UserReply,
     Child     = null,
     Exception = res.IsFaulted
                         ? "RESPERR"
                         : null,
     To          = to.ToString(),
     RequestId   = res.RequestId,
     MessageId   = Guid.NewGuid(),
     Sender      = res.ReplyFrom.ToString(),
     ReplyTo     = res.ReplyTo.ToString(),
     ContentType = res.Message.GetType().AssemblyQualifiedName,
     Content     = JsonConvert.SerializeObject(res.Message, ActorSystemConfig.Default.JsonSerializerSettings),
     SessionId   = sessionId.Map(s => s.Value).IfNoneUnsafe(() => null)
 };
Exemplo n.º 22
0
 public static string ClusterSettingsKey(ProcessId pid) =>
 ClusterKey(pid) + "@settings";
Exemplo n.º 23
0
 public TerminatedMessage(ProcessId id)
 {
     Id = id;
 }
Exemplo n.º 24
0
 public static string ClusterInboxKey(ProcessId pid, string type) =>
 ClusterKey(pid) + "-" + type + "-inbox";
Exemplo n.º 25
0
 public Unit Ask(object message, ProcessId sender) =>
 TellNoIO(message, sender, "user", Message.Type.User, Message.TagSpec.UserAsk);
Exemplo n.º 26
0
 public static string ClusterInboxNotifyKey(ProcessId pid, string type) =>
 ClusterInboxKey(pid, type) + "-notify";
Exemplo n.º 27
0
 public Unit DispatchUnWatch(ProcessId watching) =>
 TellSystem(SystemMessage.DispatchUnWatch(watching), watching);
Exemplo n.º 28
0
 public static string ClusterUserInboxNotifyKey(ProcessId pid) =>
 ClusterInboxNotifyKey(pid, "user");
Exemplo n.º 29
0
 public Unit TellUserControl(UserControlMessage message, ProcessId sender) =>
 Tell(message, Schedule.Immediate, sender, "user", Message.Type.UserControl, message.Tag);
Exemplo n.º 30
0
 internal IActorDispatch GetPluginDispatcher(ProcessId pid) =>
 GetProcessSelector(pid)
 .Map(selector => new ActorDispatchGroup(selector(pid.Skip(2)), Settings.TransactionalIO) as IActorDispatch)
 .IfNone(() => new ActorDispatchNotExist(pid));