hollywood icon indicating copy to clipboard operation
hollywood copied to clipboard

`Context.Child`'s signature & documentation is unclear

Open ThomasGormley opened this issue 1 year ago • 2 comments

It is currently not very clear what the id argument on Context.Child should really represent when you want to find the PID of a child process.

// Child will return the PID of the child (if any) by the given name/id.
// PID will be nil if it could not find it.
func (c *Context) Child(id string) *PID {

It would be good if the documentation would include that you must join: the parent ID, child name, and child ID with a / and provide that string to the method. I'm happy to make that change if it seems reasonable.

In the future, is there any reason that the implementation wouldn't handle finding the parent ID, and joining with the separator, making a signature something like below?

func (c *Context) Child(childName, id string) *PID {

Thanks

ThomasGormley avatar Oct 19 '24 12:10 ThomasGormley

just spent some time over this, what worked for me was:

func (a Actor) Something(msg Message) {
   pid := c.SpawnChild(led.NewLedEngine(options), msg)
   a.pid = pid.ID  // myName/34534523452345/msg/4563456356345
}

and that I could use in another case with also c.Child(a.pid)

moosemanf avatar Nov 02 '24 00:11 moosemanf

I'm taking this in consideration in a next release. thanks for the feedback @moosemanf @ThomasGormley

anthdm avatar Jan 03 '25 15:01 anthdm