Struct MessageBrokerPublisherCollection
- Namespace
- LfrlAnvil.MessageBroker.Client
- Assembly
- LfrlAnvil.MessageBroker.Client.dll
Represents a collection of MessageBrokerPublisher instances.
public readonly struct MessageBrokerPublisherCollection
- Inherited Members
Properties
Count
Specifies the number of publishers.
public int Count { get; }
Property Value
Methods
BindAsync(string, string?, bool)
Attempts to bind the client to a channel as a message publisher.
public ValueTask<Result<MessageBrokerBindPublisherResult?>> BindAsync(string channelName, string? streamName = null, bool isEphemeral = false)
Parameters
channelNamestringUnique name of the channel to bind as publisher to.
streamNamestringOptional unique name of the stream to which to push messages. Equal to the provided
channelNameby default.isEphemeralboolSpecifies whether the publisher will be ephemeral. Equal to false by default.
Returns
- ValueTask<Result<MessageBrokerBindPublisherResult?>>
A task that represents the operation, which returns a Result<T> instance, with underlying MessageBrokerBindPublisherResult instance.
Remarks
Unexpected errors encountered during publisher binding attempt will cause the client to be automatically disposed. Returned Result<T> will only be valid when either the client has been successfully bound as publisher to the channel on the server side, or the client is already locally bound as publisher to the channel, which will cancel the request to the server.
Exceptions
- ArgumentOutOfRangeException
When
channelNameorstreamName(if not null) length is less than 1 or greater than 512.- MessageBrokerClientDisposedException
When client has already been disposed.
- MessageBrokerClientStateException
When client is not disposed and not in Running state.
GetAll()
Returns all publishers.
[Pure]
public ReadOnlyArray<MessageBrokerPublisher> GetAll()
Returns
- ReadOnlyArray<MessageBrokerPublisher>
All publishers.
TryGetByChannelId(int)
Attempts to return a publisher by related channel id.
[Pure]
public MessageBrokerPublisher? TryGetByChannelId(int channelId)
Parameters
channelIdintUnique id of the channel to which the publisher is related.
Returns
- MessageBrokerPublisher
MessageBrokerPublisher instance associated with the provided
channelIdor null, when such a publisher does not exist.
TryGetByChannelName(string)
Attempts to return a publisher by related channel name.
[Pure]
public MessageBrokerPublisher? TryGetByChannelName(string channelName)
Parameters
channelNamestringUnique name of the channel to which the publisher is related.
Returns
- MessageBrokerPublisher
MessageBrokerPublisher instance associated with the provided
channelNameor null, when such a publisher does not exist.
UnbindAsync(string)
Attempts to unbind a publisher from the provided channel.
public ValueTask<Result<MessageBrokerUnbindPublisherResult>> UnbindAsync(string channelName)
Parameters
channelNamestringName of the channel to unbind a publisher from.
Returns
- ValueTask<Result<MessageBrokerUnbindPublisherResult>>
A task that represents the operation, which returns a Result<T> instance, with underlying MessageBrokerUnbindPublisherResult instance.
Remarks
Unexpected errors encountered during publisher unbinding will cause the client to be automatically disposed. Returned Result<T> will only be valid when either the publisher has been successfully unbound from the channel on the server side, or the publisher is already locally unbound from the channel, which will cancel the request to the server.
Exceptions
- ArgumentOutOfRangeException
When
channelNamelength is less than 1 or greater than 512.- MessageBrokerClientDisposedException
When client has already been disposed.
- MessageBrokerClientStateException
When client is not disposed and not in Running state.