Class EventBus
One endpoint on an event bus.
public sealed class EventBus : IDisposable
- Inheritance
-
EventBus
- Implements
- Inherited Members
Remarks
One publisher, many subscribers, inside a single process. It is how the parts of a gateway talk to each other without knowing about each other, so a sampler can announce a reading and whatever cares about readings picks it up.
An endpoint only sees events published after it existed, so subscribe before publishing anything it needs to see.
Constructors
EventBus(int)
Creates an event bus.
public EventBus(int capacity = 64)
Parameters
capacityintHow many events a slow subscriber may fall behind before it starts missing them.
Exceptions
- PamojaException
The native bus could not be created.
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
NextAsync()
Waits for the next event on this endpoint.
public Task<byte[]?> NextAsync()
Returns
Exceptions
- PamojaException
The native call failed.
PublishAsync(ReadOnlyMemory<byte>)
Publishes an event to every subscriber.
public Task PublishAsync(ReadOnlyMemory<byte> payload)
Parameters
payloadReadOnlyMemory<byte>The event bytes.
Returns
Exceptions
- PamojaException
The bus has shut down.
Subscribe()
Takes another endpoint on the same bus.
public EventBus Subscribe()
Returns
- EventBus
The new endpoint.
Exceptions
- PamojaException
The native call failed.