We discussed potential improvements for the current event bus in tempestphp/tempest-framework#6. This issue lists those improvements.
Transports: A driver (for lack of a better term) that the event bus uses to interact with queues and topics. Multiple can be registered, but Tempest ships with one defined by default that handles all topics. We might have to split these into SynchronousTransport and AsynchronousTransport interfaces.
Queues: A channel for events to go to
Topics: Specific events that a listener might subscribe to (e.g., pets.*)
In the configuration of a transport, we can define what topics we are interested in and/or handle some basic routing to queues. For example:
new GenericEventBus(
new EventBusConfig(
transports: [
// Tempest transport registered by default,
// sufficient for most.
new Transport(
driver: new TempestSynchronousDriver(),
topics: [
Topic::all(), // Basically Topic::new('*')->toQueue('*')
]
),
// RabbitMQ transport which allows cross-platform event handling
// but restricted to pets!
new Transport(
driver: new RabbitMqDriver(host: 'localhost'),
topics: [
Topic::new('pets.*')->toQueue('pets'),
]
),
]
)
);
#[Topic('pets.cats')]
final readonly class ItHappened
{ /* … */ }
We discussed potential improvements for the current event bus in tempestphp/tempest-framework#6. This issue lists those improvements.
SynchronousTransport
andAsynchronousTransport
interfaces.pets.*
)In the configuration of a transport, we can define what topics we are interested in and/or handle some basic routing to queues. For example:
This API can still change.