public void ProcessIdTest()
        {
            ProcessId pid = "/root/user/test";

            Assert.True(pid.Path == "/root/user/test");
            Assert.True(pid.GetName().Value == "test");
            Assert.True(pid.Child("ing").Path == "/root/user/test/ing");

            var json = JsonConvert.SerializeObject(pid);

            pid = JsonConvert.DeserializeObject <ProcessId>(json);

            Assert.True(pid.Path == "/root/user/test");
            Assert.True(pid.GetName().Value == "test");
            Assert.True(pid.Child("ing").Path == "/root/user/test/ing");
        }
示例#2
0
 /// <summary>
 /// Register as a named process
 /// </summary>
 public static ProcessId Register <T>(this ProcessId self, ProcessFlags flags = ProcessFlags.Default) =>
 ActorContext.Register <T>(self.GetName(), self, flags);
 /// <summary>
 /// Register a named process (a kind of DNS for Processes).
 ///
 /// If the Process is visible to the cluster (PersistInbox) then the
 /// registration becomes a permanent named look-up until Process.deregister
 /// is called.
 ///
 /// See remarks.
 /// </summary>
 /// <remarks>
 /// Multiple Processes can register under the same name.  You may use
 /// a dispatcher to work on them collectively (wherever they are in the
 /// cluster).  i.e.
 ///
 ///     var regd = pid.Register(name);
 ///     Dispatch.Broadcast[regd].Tell("Hello");
 ///     Dispatch.First[regd].Tell("Hello");
 ///     Dispatch.LeastBusy[regd].Tell("Hello");
 ///     Dispatch.Random[regd].Tell("Hello");
 ///     Dispatch.RoundRobin[regd].Tell("Hello");
 ///
 ///     This should be used from within a process' message loop only
 /// </remarks>
 /// <param name="name">Name to register under</param>
 /// <returns>A ProcessId that allows dispatching to the process via the name.  The result
 /// would look like /disp/reg/name</returns>
 public static ProcessId Register(this ProcessId self) =>
 ActorContext.Register(self.GetName(), self);