Пример #1
0
 internal bool IsLocal(ProcessId pid) =>
 pid.StartsWith(Root);
Пример #2
0
 public Unit UnWatch(ProcessId pid) =>
 TellSystem(SystemMessage.UnWatch(pid), pid);
Пример #3
0
 public Unit Tell(object message, Schedule schedule, ProcessId sender, Message.TagSpec tag) =>
 Tell(message, schedule, sender, "user", Message.Type.User, tag);
Пример #4
0
 public UserMessage(object message, ProcessId sender, ProcessId replyTo)
 {
     Content = message;
     Sender  = sender;
     ReplyTo = replyTo;
 }
Пример #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));
Пример #6
0
 public static string ClusterStatePubSubKey(ProcessId pid) =>
 ClusterKey(pid) + "-state-pubsub";
Пример #7
0
 public static string ClusterScheduleNotifyKey(ProcessId pid) =>
 ClusterScheduleKey(pid) + "-notify";
Пример #8
0
 public HashMap <string, ProcessId> GetChildren(ProcessId pid) =>
 GetDispatcher(pid).GetChildren();
Пример #9
0
 public Unit Kill(ProcessId pid, bool maintainState) =>
 maintainState
         ? GetDispatcher(pid).Shutdown()
         : GetDispatcher(pid).Kill();
Пример #10
0
 public Unit TellUserControl(ProcessId pid, UserControlMessage message) =>
 GetDispatcher(pid).TellUserControl(message, Self);
Пример #11
0
 public Unit TellSystem(ProcessId pid, SystemMessage message) =>
 GetDispatcher(pid).TellSystem(message, Self);
Пример #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);
Пример #13
0
 public Unit Ask(ProcessId pid, object message, ProcessId sender) =>
 GetDispatcher(pid).Ask(message, sender.IsValid ? sender : Self);
Пример #14
0
 internal bool IsDisp(ProcessId pid) =>
 pid.value.IsDisp;
Пример #15
0
 public static string ClusterSystemInboxNotifyKey(ProcessId pid) =>
 ClusterInboxNotifyKey(pid, "system");
Пример #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));
        }
Пример #17
0
 public static string ClusterMetaDataKey(ProcessId pid) =>
 ClusterKey(pid) + "-metadata";
Пример #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)));
        }
Пример #19
0
 public static string ClusterScheduleKey(ProcessId pid) =>
 $"/__schedule{ClusterKey(pid)}-user-schedule";
Пример #20
0
 public static string ClusterKey(ProcessId pid) =>
 pid.Path;
Пример #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)
 };
Пример #22
0
 public static string ClusterSettingsKey(ProcessId pid) =>
 ClusterKey(pid) + "@settings";
Пример #23
0
 public TerminatedMessage(ProcessId id)
 {
     Id = id;
 }
Пример #24
0
 public static string ClusterInboxKey(ProcessId pid, string type) =>
 ClusterKey(pid) + "-" + type + "-inbox";
Пример #25
0
 public Unit Ask(object message, ProcessId sender) =>
 TellNoIO(message, sender, "user", Message.Type.User, Message.TagSpec.UserAsk);
Пример #26
0
 public static string ClusterInboxNotifyKey(ProcessId pid, string type) =>
 ClusterInboxKey(pid, type) + "-notify";
Пример #27
0
 public Unit DispatchUnWatch(ProcessId watching) =>
 TellSystem(SystemMessage.DispatchUnWatch(watching), watching);
Пример #28
0
 public static string ClusterUserInboxNotifyKey(ProcessId pid) =>
 ClusterInboxNotifyKey(pid, "user");
Пример #29
0
 public Unit TellUserControl(UserControlMessage message, ProcessId sender) =>
 Tell(message, Schedule.Immediate, sender, "user", Message.Type.UserControl, message.Tag);
Пример #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));