internal bool IsLocal(ProcessId pid) => pid.StartsWith(Root);
public Unit UnWatch(ProcessId pid) => TellSystem(SystemMessage.UnWatch(pid), pid);
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; }
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));
public static string ClusterStatePubSubKey(ProcessId pid) => ClusterKey(pid) + "-state-pubsub";
public static string ClusterScheduleNotifyKey(ProcessId pid) => ClusterScheduleKey(pid) + "-notify";
public HashMap <string, ProcessId> GetChildren(ProcessId pid) => GetDispatcher(pid).GetChildren();
public Unit Kill(ProcessId pid, bool maintainState) => maintainState ? GetDispatcher(pid).Shutdown() : GetDispatcher(pid).Kill();
public Unit TellUserControl(ProcessId pid, UserControlMessage message) => GetDispatcher(pid).TellUserControl(message, Self);
public Unit TellSystem(ProcessId pid, SystemMessage message) => GetDispatcher(pid).TellSystem(message, Self);
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);
public Unit Ask(ProcessId pid, object message, ProcessId sender) => GetDispatcher(pid).Ask(message, sender.IsValid ? sender : Self);
internal bool IsDisp(ProcessId pid) => pid.value.IsDisp;
public static string ClusterSystemInboxNotifyKey(ProcessId pid) => ClusterInboxNotifyKey(pid, "system");
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)); }
public static string ClusterMetaDataKey(ProcessId pid) => ClusterKey(pid) + "-metadata";
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))); }
public static string ClusterScheduleKey(ProcessId pid) => $"/__schedule{ClusterKey(pid)}-user-schedule";
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) };
public static string ClusterSettingsKey(ProcessId pid) => ClusterKey(pid) + "@settings";
public TerminatedMessage(ProcessId id) { Id = id; }
public static string ClusterInboxKey(ProcessId pid, string type) => ClusterKey(pid) + "-" + type + "-inbox";
public Unit Ask(object message, ProcessId sender) => TellNoIO(message, sender, "user", Message.Type.User, Message.TagSpec.UserAsk);
public static string ClusterInboxNotifyKey(ProcessId pid, string type) => ClusterInboxKey(pid, type) + "-notify";
public Unit DispatchUnWatch(ProcessId watching) => TellSystem(SystemMessage.DispatchUnWatch(watching), watching);
public static string ClusterUserInboxNotifyKey(ProcessId pid) => ClusterInboxNotifyKey(pid, "user");
public Unit TellUserControl(UserControlMessage message, ProcessId sender) => Tell(message, Schedule.Immediate, sender, "user", Message.Type.UserControl, message.Tag);
internal IActorDispatch GetPluginDispatcher(ProcessId pid) => GetProcessSelector(pid) .Map(selector => new ActorDispatchGroup(selector(pid.Skip(2)), Settings.TransactionalIO) as IActorDispatch) .IfNone(() => new ActorDispatchNotExist(pid));