lefuturiste / jobatator-php
jobatator PHP 客户端
v0.7
2021-04-05 09:09 UTC
Requires
- php: >=7.4
- ext-json: *
- ext-sockets: *
- clue/socket-raw: ^1.4
Requires (Dev)
- phpunit/phpunit: >=7.4
README
使用此库在 jobatator 服务器上发布和消费作业。
需求
- php >= 7.4
- ext-json
- ext-sockets
- clue/socket-raw
发布者使用方法
$client = new \Lefuturiste\Jobatator\Client( "localhost", "8962", "my_username", "my_password", "my_group" ); // return true if the connexion succeeded $client->createConnexion(); // return true if publish succeeded $client->publish("my_job_type", ["payload" => ["something" => 12]]);
消费者使用方法
$client = new \Lefuturiste\Jobatator\Client( "localhost", "8962", "my_username", "my_password", "my_group" ); $client->createConnexion(); $client->setRootValue("My root value"); // can be a container interface for example $client->addHandler("my_job_type", function(array $payload, $rootValue) { echo "Job handler!"; // you can use the $rootValue var to get back your $rootValue variable }); $client->startWorker(); // will listen forever until the process stop