2017 © Pedro PelĆ”ez
 

library worker

The Hoa\Worker library.

image

hoa/worker

The Hoa\Worker library.

  • Monday, January 16, 2017
  • by Hoa
  • Repository
  • 14 Watchers
  • 21 Stars
  • 235 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 11 Forks
  • 0 Open issues
  • 11 Versions
  • 0 % Grown

The README.md

Hoa , (*1)


Build status Code coverage Packagist License , (*2)

Hoa is a modular, extensible and structured set of PHP libraries.
Moreover, Hoa aims at being a bridge between industrial and research worlds. , (*3)

Hoa\Worker

Help on IRC Help on Gitter Documentation Board, (*4)

This library allows to create shared workers in order to lift out some heavy and blocking tasks., (*5)

Learn more., (*6)

Installation

With Composer, to include this library into your dependencies, you need to require hoa/worker:, (*7)

$ composer require hoa/worker '~3.0'

For more installation procedures, please read the Source page., (*8)

Testing

Before running the test suites, the development dependencies must be installed:, (*9)

$ composer install

Then, to run all the test suites:, (*10)

$ vendor/bin/hoa test:run

For more information, please read the contributor guide., (*11)

Quick usage

As a quick overview, we see how to create a worker and how to communicate with it., (*12)

Create a worker

First, we need to register the worker (i.e. creating a .wid file), called demorker:, (*13)

if (false === Hoa\Worker\Run::widExists('demorker')) {
    Hoa\Worker\Run::register('demorker', 'tcp://127.0.0.1:123456');
}

Then, we start the worker (with a password) and we listen to messages:, (*14)

$worker = new Hoa\Worker\Backend\Shared('demorker', 'iamapassword');
$worker->on('message', function(Hoa\Event\Bucket $bucket) {
    $data = $bucket->getData();
    // compute $data['message'].
});
$worker->run();

The message indicates a task to do (sending an email, create some archives, update the database, send some notifications…)., (*15)

We are also able to manage all workers from a CLI., (*16)

Communicate with a worker

Second, since the worker is running, we can communicate with it from our application. Thus:, (*17)

$worker = new Hoa\Worker\Shared('demorker');
$worker->postMessage('mail gordon@freeman.hl Hello Gordon!');

We are able to send everything that can be serialized., (*18)

Documentation

The hack book of Hoa\Worker contains detailed information about how to use this library and how it works., (*19)

To generate the documentation locally, execute the following commands:, (*20)

$ composer require --dev hoa/devtools
$ vendor/bin/hoa devtools:documentation --open

More documentation can be found on the project's website: hoa-project.net., (*21)

Getting help

There are mainly two ways to get help:, (*22)

Contribution

Do you want to contribute? Thanks! A detailed contributor guide explains everything you need to know., (*23)

License

Hoa is under the New BSD License (BSD-3-Clause). Please, see LICENSE for details., (*24)

The Versions

17/08 2015

2.15.08.17

2.15.08.17 http://hoa-project.net/

The Hoa\Worker library.

  Sources   Download

BSD-3-Clause

The Requires

 

library worker daemon shared

29/05 2015

2.15.05.29

2.15.05.29 http://hoa-project.net/

The Hoa\Worker library.

  Sources   Download

BSD-3-Clause

The Requires

 

library worker daemon shared

26/02 2015

2.15.02.26

2.15.02.26 http://hoa-project.net/

The Hoa\Worker library.

  Sources   Download

BSD-3-Clause

The Requires

 

library worker daemon shared

09/12 2014

2.14.12.10

2.14.12.10 http://hoa-project.net/

The Hoa\Worker library.

  Sources   Download

BSD-3-Clause

The Requires

 

library worker daemon shared

23/09 2014

2.14.09.23

2.14.09.23 http://hoa-project.net/

The Hoa\Worker library.

  Sources   Download

BSD-3-Clause

The Requires

 

library worker daemon shared

17/09 2014

2.14.09.17

2.14.09.17 http://hoa-project.net/

The Hoa\Worker library.

  Sources   Download

BSD-3-Clause

The Requires

 

library worker daemon shared

16/09 2014

1.14.09.16

1.14.09.16 http://hoa-project.net/

The Hoa\Worker library.

  Sources   Download

BSD-3-Clause

The Requires

 

library worker daemon shared