Interface IPubsubApi
The gateway's Pubsub service: publish CloudEvents to topics and subscribe to them. A
failed publish is a RpcException with an ErrorInfo; a
PublishEvents call that published only some events is Aborted
(PartialFailure) with a PublishEventsFailure detail.
public interface IPubsubApi
Methods
ListTopicsAsync(CancellationToken)
Task<IReadOnlyList<TopicInfo>> ListTopicsAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
- Task<IReadOnlyList<TopicInfo>>
PublishEventAsync(string, CloudEvent, CancellationToken)
Task<PublishResponse> PublishEventAsync(string topic, CloudEvent cloudevent, CancellationToken cancellationToken = default)
Parameters
topicstringcloudeventCloudEventcancellationTokenCancellationToken
Returns
- Task<PublishResponse>
PublishEventsAsync(IEnumerable<(string Topic, CloudEvent CloudEvent)>, CancellationToken)
Task<PublishEventsResponse> PublishEventsAsync(IEnumerable<(string Topic, CloudEvent CloudEvent)> events, CancellationToken cancellationToken = default)
Parameters
eventsIEnumerable<(string Topic, CloudEvent CloudEvent)>cancellationTokenCancellationToken
Returns
- Task<PublishEventsResponse>
PublishEventsPacedAsync(IEnumerable<(string Topic, CloudEvent CloudEvent)>, bool, CancellationToken)
Publishes several events in one paced call: the gateway holds it while a consumer of
one of the topics is behind, so a source that can wait (a replay, a bulk publish)
loses no event past the stream's retention. Never for live data. A call held for the
gateway's whole wait ends with ResourceExhausted and publishes nothing;
retryHeld publishes it again until it goes through.
An implementation that cannot pace (a local test double) throws NotSupportedException.
Task<PublishEventsResponse> PublishEventsPacedAsync(IEnumerable<(string Topic, CloudEvent CloudEvent)> events, bool retryHeld = false, CancellationToken cancellationToken = default)
Parameters
eventsIEnumerable<(string Topic, CloudEvent CloudEvent)>retryHeldboolcancellationTokenCancellationToken
Returns
- Task<PublishEventsResponse>
PublishWithResultAsync(string, CloudEvent, string, TimeSpan?, string?, CancellationToken)
Task<SubscribeResponse> PublishWithResultAsync(string topic, CloudEvent cloudevent, string replyTopic, TimeSpan? timeout = null, string? correlationId = null, CancellationToken cancellationToken = default)
Parameters
topicstringcloudeventCloudEventreplyTopicstringtimeoutTimeSpan?correlationIdstringcancellationTokenCancellationToken
Returns
- Task<SubscribeResponse>
SubscribeAsync(IEnumerable<string>, CancellationToken)
Subscribes to topics; completes once the subscription is live, so a
request published after the await cannot outrun it (see Subscription).
Task<Subscription> SubscribeAsync(IEnumerable<string> topics, CancellationToken cancellationToken = default)
Parameters
topicsIEnumerable<string>cancellationTokenCancellationToken