PipeTo
Last updated
Last updated
The PipeTo
method is designed to handle cases where an actor needs to interact with an external service or perform a long-running task asynchronously. Instead of blocking its mailbox while waiting for a task to complete, an actor can launch the task and then “pipe” its successful result to the intended recipient’s mailbox as a message to process. This approach keeps the actor responsive and maintains the single-threaded execution guarantee of actor message processing. This feature is available on the actor reference as well as on the.
By integrating the PipeTo
feature into your actor workflows, you can seamlessly combine asynchronous operations with the actor message-processing model, ensuring high throughput and responsiveness even when dealing with external or long-running tasks.
Use the PipeTo feature when:
Integrating External Services: When an actor makes an asynchronous call to an external API or service, the future result (task) can be piped to itself or another actor for further processing.
Non-blocking Asynchronous Processing: Avoids blocking the actor’s message loop by offloading the waiting for task completion to a separate goroutine.
Decoupled Response Handling: The asynchronous task’s result is delivered as a message to the target actor’s mailbox, making it part of the actor’s regular message-processing flow.
Currently, this functionality is not supported for remote or clustered deployments.