コード例 #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));