示例#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);
 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;
 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";
 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));