-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
interface Correlatable
{
/**
* @throws InvalidEventGiven
*/
public function correlate(Event\Envelope $envelope): Listener\Id;
}class OrderSaga implements Listener, Listener\Correlatable
{
use Listener\Correlating;
public static function correlateByOrderPlaced(OrderPlaced $event): OrderSaga\Id
{
return new OrderSaga\Id($event->orderId);
}
public static function correlateByInventoryReserved(InventoryReserved $event): OrderSaga\Id
{
return new OrderSaga\Id($event->orderId);
}
// etc
}class Factory implements Listener\Factory
{
public function create(OrderSaga\Id $id): Listener
{
return new OrderSaga($id, $this->commandBus);
}
/**
* Somehow automate or make it not part of the factory but part of the Streak infrastructure.
*/
public function createFor(Event\Envelope $envelope): Listener
{
return OrderSaga::correlate($envelope);
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels