以下のでいけそう。$timeoutでtimeoutできるかを確認。(試したけれど、だめそう).
$worker->register_function($funcname, $timeout, $subref)
Registers the function $funcname as being provided by the worker $worker, and advertises these capabilities to all of the job servers defined in this worker.
$subref must be a subroutine reference that will be invoked when the worker receives a request for this function. It will be passed a Gearman::Job object representing the job that has been received by the worker.
$timeout is an optional parameter specifying how long the jobserver will wait for your subroutine to give an answer. Exceeding this time will result in the jobserver reassigning the task and ignoring your result. This prevents a gimpy worker from ruining the 'user experience' in many situations.
The subroutine reference can return a return value, which will be sent back to the job server.
流れ
これだと、enqueueする側と、実際のJobを処理する側、処理結果を受ける側のサーバーを分離できる。
Asyncはもうちょっと使わないとわからないなぁ。Danga::Socketとepollをまだ理解しきれてない。
telnet localhost 7003でgearmandの管理がコマンドベースでできます。
jobの関数名 キュー中のジョブのトータル数 実行中のjobの数
の順で表示される
登録されたWorkerのfds, IP, client ids, 登録されている関数郡の名前(そのworkerが実行できる事)
形式は、以下の通り。
fd ip.x.y.z client_id : func_a func_b func_c fd ip.x.y.z client_id : func_a func_b func_c fd ip.x.y.z client_id : func_a func_b func_c
gearmand落とす
どういうときに使うコマンドなのか、よくわからない
Gearman::Serverのversion
Ctrl+]で抜ける.
* はてなダイアリーキーワード:Gearman