indigophp / doris
Doris is a remote command bus implementation based on Bernard and Tactician
Requires
- php: >=5.4.0
- bernard/bernard: dev-master
- league/event: ~2.0.0
- league/tactician: dev-master
Requires (Dev)
- henrikbjorn/phpspec-code-coverage: ~1.0.0
- indigophp/tactician-event-decorator: dev-develop
- phpspec/phpspec: ~2.1.0
Suggests
- indigophp/tactician-event-decorator: Used for event-driven consuming logic
This package is not auto-updated.
Last update: 2022-02-01 12:43:17 UTC
README
Doris is a remote command bus implementation based on Bernard and Tactician.
Install
Via Composer
$ composer require indigophp/doris
Usage
Install Doris in both your application and (if you have any) dedicated worker package/instance.
You can run your consumer directly using your application, however you should avoid it if possible. Bootstrapping your application consumes more resource than necessary. (That said, sometimes it is simply easier.) In this case you have to make sure that you provide your consumer instance with all the data it needs: database connection details, required dependencies, etc.
Remote execution
To send a command to it's destination, simply create a remote executing command bus, and use it like you would use any other:
use Doris\RemoteCommandBus; // ...create a Bernard\Queue instance // make sure to add te appropriate serializers $commandBus = new RemoteCommandBus($queue); $commandBus->execute($command);
Consuming commands
On the other side of the message queue you must set up a consumer:
use Doris\Consumer; use Doris\Listener\CommandLimit; // ... create your inner commandBus $consumer = new Consumer; // execute maximum of 10 commands $consumer->addListener(new CommandLimit(10)); $consumer->consume($queue, $commandBus);
List of available listeners:
CommandLimit
: limits how many commands should be executedTimeLimit
: limits how long the consumer can runWait
: wait for some time at the end of every cycle
Testing
$ phpspec run
Contributing
Please see CONTRIBUTING for details.
Credits
Name refers to the film Bernard and Doris.
License
The MIT License (MIT). Please see License File for more information.