Skip to content

fix: allow Child() to accept relative 'kind/id' path (backwards compatible)#208

Open
ignoxx wants to merge 3 commits into
anthdm:masterfrom
ignoxx:fix/child-lookup-relative-path
Open

fix: allow Child() to accept relative 'kind/id' path (backwards compatible)#208
ignoxx wants to merge 3 commits into
anthdm:masterfrom
ignoxx:fix/child-lookup-relative-path

Conversation

@ignoxx

@ignoxx ignoxx commented Jan 19, 2026

Copy link
Copy Markdown

Problem

Currently, ctx.Child() requires the full PID.ID (e.g., "parent/1/worker/123") to find a child actor. This is counter-intuitive because:

  1. SpawnChild(producer, "worker", WithID("123")) accepts kind and id separately
  2. Users naturally expect ctx.Child("worker/123") to work when called from the parent actor
  3. The current behavior requires users to manually construct the full path

Related issue: #168

Solution

This PR modifies Child() to first try an exact match (for backward compatibility), then try prepending the parent's PID.ID to support the intuitive "kind/id" format.

Usage

// Spawn a child
ctx.SpawnChild(producer, "worker", WithID("123"))
// Now both work:
ctx.Child("worker/123")                    // ✅ New intuitive way
ctx.Child("parent/1/worker/123")           // ✅ Still works (backward compatible)

Previously, ctx.Child() required the full PID.ID to find a child,
which was counter-intuitive.
This change allows ctx.Child('kind/id') to work as expected while
maintaining backward compatibility with full PID.ID lookups.
@ignoxx

ignoxx commented Jan 29, 2026

Copy link
Copy Markdown
Author

@tralafiti @anthdm would be nice to have this merged :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant