/// <summary> /// Finds all *persistent* processes based on the search pattern provided. Note the returned /// ProcessIds may contain processes that aren't currently active. You can still post /// to them however. /// </summary> /// <param name="keyQuery">Key query. * is a wildcard</param> /// <returns>Matching ProcessIds</returns> public static IEnumerable <ProcessId> queryProcesses(string keyQuery, SystemName system = default(SystemName)) => ActorContext.System(system).Cluster .Map(c => c.QueryProcesses(keyQuery)) .IfNone(new ProcessId[0]);
/// <summary> /// Get a list of cluster nodes that are online /// </summary> public static HashMap <ProcessName, ClusterNode> ClusterNodes(SystemName system = default(SystemName)) => ActorContext.System(system).ClusterState?.Members ?? HashMap <ProcessName, ClusterNode>();
/// <summary> /// Finds all *persistent* registered names in a role /// </summary> /// <param name="role">Role to limit search to</param> /// <param name="keyQuery">Key query. * is a wildcard</param> /// <returns>Registered names</returns> public static IEnumerable <ProcessName> queryRegistered(ProcessName role, string keyQuery, SystemName system = default(SystemName)) => ActorContext.System(system).Cluster .Map(c => c.QueryRegistered(role.Value, keyQuery)) .IfNone(List.empty <ProcessName>());
public ActorResponse SetSystem(SystemName sys) => new ActorResponse(Message, ReplyTo.SetSystem(sys), ReplyFrom.SetSystem(sys), RequestId, ReplyType, IsFaulted);
/// <summary> /// Builds a ProcessId that represents the previous node in the role that this /// node is a part of. If there is only one node in the role then any messages /// sent will be sent to the leaf-process with itself. Unlike other Roles, you /// do not specify the role-name as the first child. /// See remarks. /// </summary> /// <remarks> /// You may create a reference to child nodes in the usual way: /// Role.Prev["user"]["child-1"][...] /// </remarks> /// <example> /// tell( Role.Prev["user"]["message-log"], "Hello" ); /// </example> public static ProcessId Prev(SystemName system = default(SystemName)) => prevRoot[Root(system).Name];
/// <summary> /// Access a setting /// If in a Process message loop, then this accesses the configuration settings /// for the Process from the the configuration file, or stored in the cluster. /// If not in a Process message loop, then this accesses 'global' configuration /// settings. /// </summary> /// <param name="name">Name of the setting</param> /// <param name="prop">If the setting is a complex value (like a map or record), then /// this selects the property of the setting to access</param> /// <returns>Optional configuration setting value</returns> public static T read <T>(string name, string prop, T defaultValue, SystemName system = default(SystemName)) => InMessageLoop ? ActorContext.System(Self).Settings.GetProcessSetting(Self, name, prop, defaultValue, ActorContext.Request.ProcessFlags) : ActorContext.System(system).Settings.GetRoleSetting(name, prop, defaultValue);
/// <summary> /// Starts a new session in the Process system with the specified /// session ID /// </summary> /// <param name="sid">Session ID</param> /// <param name="timeout">Session timeout</param> public static SessionId sessionStart(SessionId sid, Time timeout, SystemName system) { ActorContext.System(system).Sessions.Start(sid, (int)(timeout / 1.Seconds())); ActorContext.SessionId = sid; return(sid); }
public TerminatedMessage SetSystem(SystemName sys) => new TerminatedMessage(Id.SetSystem(sys));
/// <summary> /// Root process ID /// The Root process is the parent of all processes /// </summary> public static ProcessId Root(SystemName system = default(SystemName)) => ActorContext.System(system).Root;
public SystemUnLinkChildMessage SetSystem(SystemName sys) => new SystemUnLinkChildMessage(Child.SetSystem(sys));
public UserMessage SetSystem(SystemName sys) => new UserMessage(Content, Sender.SetSystem(sys), ReplyTo.SetSystem(sys));
public SystemChildFaultedMessage SetSystem(SystemName sys) => new SystemChildFaultedMessage(Child.SetSystem(sys), Sender.SetSystem(sys), Exception, Message);
internal ShutdownCancellationToken(SystemName sys) { System = sys; }
public static Map <ProcessName, ClusterNode> Nodes(ProcessId leaf, SystemName system = default(SystemName)) => ClusterNodes(system).Filter(node => node.Role == leaf.Take(1).Name);
/// <summary> /// Finds all *persistent* processes based on the search pattern provided and then returns the /// meta-data associated with them. /// </summary> /// <param name="keyQuery">Key query. * is a wildcard</param> /// <returns>Map of ProcessId to ProcessMetaData</returns> public static HashMap <ProcessId, ProcessMetaData> queryProcessMetaData(string keyQuery, SystemName system = default(SystemName)) => ActorContext.System(system).Cluster .Map(c => c.QueryProcessMetaData(keyQuery)) .IfNone(HashMap.empty <ProcessId, ProcessMetaData>());
/// <summary> /// User process ID /// The User process is the default entry process, your first process spawned /// will be a child of this process. /// </summary> public static ProcessId User(SystemName system = default(SystemName)) => ActorContext.System(system).User;
public ActorSystem(SystemName systemName, Option <ICluster> cluster, AppProfile appProfile, ProcessSystemConfig settings) { var name = GetRootProcessName(cluster); if (name.Value == "root" && cluster.IsSome) { throw new ArgumentException("Cluster node name cannot be 'root', it's reserved for local use only."); } if (name.Value == "disp" && cluster.IsSome) { throw new ArgumentException("Cluster node name cannot be 'disp', it's reserved for internal use."); } if (name.Value == "js") { throw new ArgumentException("Node name cannot be 'js', it's reserved for ProcessJS."); } SystemName = systemName; this.appProfile = appProfile; this.settings = settings; this.cluster = cluster; Ping = new Ping(this); startupTimestamp = DateTime.UtcNow.Ticks; sessionManager = new SessionManager(cluster, SystemName, appProfile.NodeName, VectorConflictStrategy.Branch); watchers = Map <ProcessId, Set <ProcessId> >(); watchings = Map <ProcessId, Set <ProcessId> >(); startupSubscription = NotifyCluster(cluster, startupTimestamp); Dispatch.init(); Role.init(cluster.Map(r => r.Role).IfNone("local")); Reg.init(); var root = ProcessId.Top.Child(GetRootProcessName(cluster)); var rootInbox = new ActorInboxLocal <ActorSystemBootstrap, Unit>(); var parent = new ActorItem(new NullProcess(SystemName), new NullInbox(), ProcessFlags.Default); var state = new ActorSystemBootstrap( this, cluster, root, null, rootInbox, cluster.Map(x => x.NodeName).IfNone(ActorSystemConfig.Default.RootProcessName), ActorSystemConfig.Default, Settings, sessionManager.Sync ); var rootProcess = state.RootProcess; state.Startup(); rootItem = new ActorItem(rootProcess, rootInbox, ProcessFlags.Default); Root = rootItem.Actor.Id; RootJS = Root["js"]; System = Root[ActorSystemConfig.Default.SystemProcessName]; User = Root[ActorSystemConfig.Default.UserProcessName]; Errors = System[ActorSystemConfig.Default.ErrorsProcessName]; DeadLetters = System[ActorSystemConfig.Default.DeadLettersProcessName]; NodeName = cluster.Map(c => c.NodeName).IfNone("user"); AskId = System[ActorSystemConfig.Default.AskProcessName]; Disp = ProcessId.Top["disp"].SetSystem(SystemName); Scheduler = System[ActorSystemConfig.Default.SchedulerName]; userContext = new ActorRequestContext( this, rootProcess.Children["user"], ProcessId.NoSender, rootItem, null, null, ProcessFlags.Default, null); rootInbox.Startup(rootProcess, parent, cluster, settings.GetProcessMailboxSize(rootProcess.Id)); }
/// <summary> /// Dead letters process /// Subscribe to it to monitor the failed messages (<see cref="subscribe(ProcessId)"/>) /// </summary> public static ProcessId DeadLetters(SystemName system = default(SystemName)) => ActorContext.System(system).DeadLetters;
public NullProcess(SystemName system) { System = system; }
/// <summary> /// Errors process /// Subscribe to it to monitor the errors thrown /// </summary> public static ProcessId Errors(SystemName system = default(SystemName)) => ActorContext.System(system).Errors;
public ActorRequest SetSystem(SystemName sys) => new ActorRequest(Message, To.SetSystem(sys), ReplyTo.SetSystem(sys), RequestId);
/// <summary> /// Shutdown all processes on the specified process-system /// </summary> public static Unit shutdownSystem(SystemName system) => ActorContext.StopSystem(system);
/// <summary> /// Set the Process system that this ProcessId belongs to /// </summary> public ProcessId SetSystem(SystemName system) => IsValid ? new ProcessId(value.Parts, system, Name, Path) : this;
/// <summary> /// Builds a ProcessId that represents the next node in the role that this node /// is a part of. If there is only one node in the role then any messages sent /// will be sent to the leaf-process with itself. Unlike other Roles, you do /// not specify the role-name as the first child. /// See remarks. /// </summary> /// <remarks> /// You may create a reference to child nodes in the usual way: /// Role.Next["user"]["child-1"][...] /// </remarks> /// <example> /// tell( Role.Next["user"]["message-log"], "Hello" ); /// </example> public static ProcessId Next(SystemName system = default(SystemName)) => nextRoot[Root(system).Name];