diff options
author | Valery Piashchynski <[email protected]> | 2020-12-15 13:31:40 +0300 |
---|---|---|
committer | GitHub <[email protected]> | 2020-12-15 13:31:40 +0300 |
commit | b44d272312389691920e42e5295395bef0d3b769 (patch) | |
tree | 1c826999423e59db5b7dab1184725e22468ecfbd /tests/src/WorkerInterface.php | |
parent | 673da74925dee5c62064d3304289ae81cb499217 (diff) | |
parent | 7b0a6720c21056ed4b922eb5b1b8a91a44dc3638 (diff) |
Merge pull request #447 from spiral/feature/goridge3
Feature/goridge3
Diffstat (limited to 'tests/src/WorkerInterface.php')
-rw-r--r-- | tests/src/WorkerInterface.php | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/src/WorkerInterface.php b/tests/src/WorkerInterface.php new file mode 100644 index 00000000..bf0b6e06 --- /dev/null +++ b/tests/src/WorkerInterface.php @@ -0,0 +1,55 @@ +<?php + +/** + * High-performance PHP process supervisor and load balancer written in Go. + * + * @author Wolfy-J + */ + +declare(strict_types=1); + +namespace Spiral\RoadRunner; + +use Spiral\Goridge\Exception\GoridgeException; +use Spiral\RoadRunner\Exception\RoadRunnerException; + +interface WorkerInterface +{ + /** + * Wait for incoming payload from the server. Must return null when worker stopped. + * + * @return Payload|null + * @throws GoridgeException + * @throws RoadRunnerException + */ + public function waitPayload(): ?Payload; + + /** + * Respond to the server with the processing result. + * + * @param Payload $payload + * @throws GoridgeException + */ + public function respond(Payload $payload): void; + + /** + * Respond to the server with an error. Error must be treated as TaskError and might not cause + * worker destruction. + * + * Example: + * + * $worker->error("invalid payload"); + * + * @param string $error + * @throws GoridgeException + */ + public function error(string $error): void; + + /** + * Terminate the process. Server must automatically pass task to the next available process. + * Worker will receive stop command after calling this method. + * + * Attention, you MUST use continue; after invoking this method to let rr to properly stop worker. + */ + public function stop(): void; +} |