phpgears/event-sourcing-async

dev-master 2020-03-07 00:23 UTC

This package is auto-updated.

Last update: 2024-11-07 10:34:55 UTC


README

PHP version Latest Version License

Build Status Style Check Code Quality Code Coverage

Total Downloads Monthly Downloads

Event Sourcing Async

Async decorator for Event Sourcing events and Async Event Bus

Installation

Composer

composer require phpgears/event-sourcing-async

Usage

Require composer autoload file

require './vendor/autoload.php';

This package adds a new Gears\EventSourcing\Async\Serializer\JsonEventSerializer serializer, as a general serializer allowing maximum compatibility in case of events being handled by other systems, to allow Gears\EventSourcing\Event\AggregateEvent events to be used in Async event bus

use Gears\Event\Async\AsyncEventBus;
use Gears\EventSourcing\Async\Serializer\JsonEventSerializer;
use Gears\Event\Async\Discriminator\ParameterEventDiscriminator;

/* @var \Gears\Event\EventBus $eventBus */

/* @var Gears\Event\Async\EventQueue $eventQueue */
$eventQueue = new CustomEventQueue(new JsonEventSerializer());

$asyncEventBus new AsyncEventBus(
    $eventBus,
    $eventQueue,
    new ParameterEventDiscriminator('async')
);

$asyncEvent = new CustomEvent(['async' => true]);

$asyncEventBus->dispatch($asyncEvent);

Refer to phpgears/event-async for more information

Contributing

Found a bug or have a feature request? Please open a new issue. Have a look at existing issues before.

See file CONTRIBUTING.md

License

See file LICENSE included with the source code for a copy of the license terms.