Gearman extension

Hello everybody,

I’m doing a simple extension for gearman. Follows:


<?php 

class Gearman extends CApplicationComponent

{


    public $servers;

    protected $client;

    protected $worker;


    public function init()

    {

        parent::init();

    }


    protected function setServers($instance)

    {

        foreach ($this->servers as $s)

        {

            $instance->addServer($s['host'], $s['port']);

        }


        return $instance;

    }


    public function client()

    {

        if (!$this->client)

        {

            $this->client = $this->setServers(new GearmanClient());

        }


        return $this->client;

    }


    public function worker()

    {

        if (!$this->worker)

        {

            $this->worker = $this->setServers(new GearmanWorker());

        }


        return $this->worker;

    }


}

?>

The configuration would look like:




'components' => array(

    'gearman' => array(

                'class' => 'ext.Gearman',

                'servers' => array(

                       array('host' => '127.0.0.1', 'port' => 4731),

                ),

         ),

    ),



Does anyone have any suggestions of what might be useful for this extension?

I didn’t know what it was, so I binged it:

Here:

Gearman

Am I right?

Interesting stuff. :)

Yep, you’re right! Sorry I’m new at this forum and I cannot post links. :)

While I’ve been aware of Gearman for years, I’ve never actually used it.

So I assume we would need to start Yii from console to enable the Gearman worker, and then pass jobs from the web-app?

BTW, have you seen this? Looks pretty complete: https://github.com/mitallast/yii-gearman

I’m author of yii-gearman . User intel352 from github asked me create translate. I’m wrote it at Wiki pages.

I’m sorry, I haven’t access to post links.