internal static IActorDispatch GetRegisteredDispatcher(ProcessId pid) => GetRegisteredItem().Match( Some: regd => pid.Count() == 2 ? new ActorDispatchLocal(regd) : regd.Actor.Children.ContainsKey(pid.Skip(2).GetName().Value) ? GetDispatcher(pid.Tail(), rootItem, pid) : cluster.Match <IActorDispatch>( Some: c => new ActorDispatchRemote(pid.Skip(1), c), None: () => new ActorDispatchNotExist(pid)), None: () => new ActorDispatchNotExist(pid));
Unit Tell(object message, ProcessId sender, string inbox, Message.Type type, Message.TagSpec tag) { var dto = RemoteMessageDTO.Create(message, ProcessId, sender, type, tag); // The standard structure for remote js relay paths are "/root/js/{connection-id}/..." var connectionId = ProcessId.Skip(2).Take(1).Name.Value; dto.To = ProcessId.Skip(3).Path; var relayMsg = new OutboundRelayMsg(connectionId, dto, dto.To, sender, dto.RequestId != -1); return(Process.tell(RelayId, relayMsg, sender)); }
internal static IActorDispatch GetPluginDispatcher(ProcessId pid) { if (pid.Count() < 3) { throw new InvalidProcessIdException("Invalid role Process ID"); } var type = pid.Skip(1).Take(1).GetName(); return(dispatchers.Find(type) .Map(selector => new ActorDispatchGroup(selector(pid.Skip(2))) as IActorDispatch) .IfNone(() => new ActorDispatchNotExist(pid))); }
public Option <ActorItem> GetLocalActor(ProcessId pid) { if (pid.System != SystemName) { return(None); } return(GetLocalActor(rootItem, pid.Skip(1), pid)); }
private static ProcessId FixRootName(string pid) { ProcessId cpid = pid; return(cpid.Take(1).GetName().Value == "root" ? Root.Append(cpid.Skip(1)) : cpid); }
internal static Option <Func <ProcessId, IEnumerable <ProcessId> > > GetProcessSelector(ProcessId pid) { if (pid.Count() < 3) { throw new InvalidProcessIdException("Invalid role Process ID"); } var type = pid.Skip(1).Take(1).GetName(); return(dispatchers.Find(type)); }
internal Option <Func <ProcessId, IEnumerable <ProcessId> > > GetProcessSelector(ProcessId pid) { if (pid.Count() < 3) { throw new InvalidProcessIdException("Invalid role Process ID"); } var type = pid.Skip(1).Take(1).Name; return(Dispatch.getFunc(type)); }
internal static IActorDispatch GetJsDispatcher(ProcessId pid) { switch (pid.Count()) { case 0: case 1: return(new ActorDispatchNotExist(pid)); // /root/js <-- relay case 2: return(GetDispatcher(pid.Skip(1), rootItem, pid)); // /root/js/{connection id} <-- relay case 3: return(GetDispatcher(pid.Skip(1), rootItem, pid)); // /root/js/{connection id}/js-root/.. --> back to JS default: return(new ActorDispatchJS(pid, pid.Take(3), rootItem.Actor.Children["js"])); } }
Option <ActorItem> GetLocalActor(ActorItem current, ProcessId walk, ProcessId pid) { if (current.Actor.Id == pid) { return(current); } var name = walk.Take(1).Name; return(from child in current.Actor.Children.Find(walk.Take(1).Name.Value) from result in GetLocalActor(child, walk.Skip(1), pid) select result); }
public static IEnumerable <ProcessId> NodeIds(ProcessId leaf) => Nodes(leaf).Values.Map(node => ProcessId.Top[node.NodeName].Append(leaf.Skip(1)));
internal static IActorDispatch GetPluginDispatcher(ProcessId pid) => GetProcessSelector(pid) .Map(selector => new ActorDispatchGroup(selector(pid.Skip(2))) as IActorDispatch) .IfNone(() => new ActorDispatchNotExist(pid));
internal static IEnumerable <ProcessId> ResolveProcessIdSelection(ProcessId pid) => GetProcessSelector(pid) .Map(selector => selector(pid.Skip(2))) .IfNone(() => new ProcessId[0]);
public static IEnumerable<ProcessId> NodeIds(ProcessId leaf) => Nodes(leaf).Values.Map(node => ProcessId.Top[node.NodeName].Append(leaf.Skip(1)));