We should decouple these from the IEventBus implementation, we shouldn't require you to implement a start and stop feature as they're not always going to apply.
For example, using Azure service bus, you can publish a message but don't necessarily have to be subscribed to a topic which causes you to receive messages as a consumer, this could also apply the other way around where you're purely a consumer and not producing any messages.
In the ServiceBus package, we already have this distinction with the sender/receivers, and use those within the concrete implementation of IEventBus, so perhaps this should be the case with the base abstractions too.
Should this actually become along the lines of:
public interface IEventBusPublisher
{
Task PublishAsync<TEvent>(TEvent @event) where TEvent : IEvent;
Task PublishAsync(IEnumerable<IEvent> events);
Task<string> PublishAsync<TEvent>(TEvent @event, DateTimeOffset publishOnUtc) where TEvent : IEvent;
// NOTE(Dan): What should happen to cancelling a message?
Task CancelScheduledMessageAsync(string identifier);
}
public interface IEventBusReceiver
{
Task StartAsync(/* Should we accept a cancellation token? */);
Task StopAsync(/* Should we accept a cancellation token? */);
}
We should decouple these from the
IEventBus
implementation, we shouldn't require you to implement a start and stop feature as they're not always going to apply.For example, using Azure service bus, you can publish a message but don't necessarily have to be subscribed to a topic which causes you to receive messages as a consumer, this could also apply the other way around where you're purely a consumer and not producing any messages.
In the ServiceBus package, we already have this distinction with the sender/receivers, and use those within the concrete implementation of
IEventBus
, so perhaps this should be the case with the base abstractions too.Should this actually become along the lines of: