OnReceive stalls every queued message. The
pipe methods offload that work: the task runs in a goroutine outside the message loop, the grain keeps processing, and
the outcome comes back as an ordinary message.
API
All three are methods on
GrainContext, so they are called from inside OnReceive.
Task signature and outcome
- Success: the
anyresult is delivered to the target as a normal message. - Failure with a grain target (
PipeToSelf,PipeToGrain): the target receives a*StatusFailuremessage carrying the error; handle it inOnReceiveviamsg.Error(). AWithTimeoutexpiry counts as a failure. - Failure with an actor target (
PipeToActor): the error follows the actor PipeTo semantics and goes to the dead-letter queue.
Options
Only one of the two may be used per call; using both returns
ErrOnlyOneOptionAllowed.
Example
fetchReportData runs; the report data (or a *StatusFailure on error or timeout)
arrives as a later message and is serialized with the grain’s other traffic.
See also
- Grains: lifecycle, identity, and messaging
- PipeTo: the actor-side API and shared option details
- Grain Reentrancy: non-blocking requests to other grains and actors