fgh151/yii2-beanstalk-singleton Trait for only one instance of beanstalk worker

librarysingletonbeanstalk

Yii2 beanstalk singleton trait

Trait for only one instance of beanstalk worker

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist fgh151/yii2-beanstalk-singleton "*"

or add

"fgh151/yii2-beanstalk-singleton": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, add trait to beanstalk controller


class TestController extends udokmeci\yii2beanstalk\BeanstalkController
{
    use fgh151\beanstalk\Singleton;

}

Now you have additional commands:

./yii test/status

it will print pid of current process or "Not active" if worker not run

./yii test/halt

it will halt current worker

PHP >= 5.4

If you use php >= 5.4, you mas override construct and destruct methods:

class BuildController extends BeanstalkController
{
    use fgh151\beanstalk\Singleton {
        Singleton::__construct as private __TraitConstruct;
        Singleton::__destruct as private __TraitDestruct;
    }

    public function __construct($id, Module $module, array $config)
    {
        $this->__TraitConstruct($id, $module, $config);
    }

    public function __destruct()
    {
        $this->__TraitDestruct();
    }
}

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

Comments



v0.0.2 is the latest of 2 releases



MIT license
Stats
0 github stars & 0 github forks
0 downloads in the last day
0 downloads in the last 30 days
20 total downloads