Class PubsubService
Implements the Pubsub gRPC service for publish/subscribe messaging via Dapr. Publish stores a CloudEvent as protobuf; Subscribe streams the stored CloudEvents, or whole batches of them to a caller that asked for it.
public class PubsubService : Pubsub.PubsubBase
- Inheritance
-
Pubsub.PubsubBasePubsubService
- Inherited Members
Constructors
PubsubService(DaprClient, DaprComponentOptions, TopicDaprSubscriptionRegistry, ILogger<PubsubService>, TopicCatalog?, IConsumerGroupPositioner?, PubsubReplayOptions?, PubsubBatchOptions?, ConsumerProgress?)
public PubsubService(DaprClient daprClient, DaprComponentOptions components, TopicDaprSubscriptionRegistry registry, ILogger<PubsubService> logger, TopicCatalog? topics = null, IConsumerGroupPositioner? history = null, PubsubReplayOptions? replay = null, PubsubBatchOptions? batch = null, ConsumerProgress? progress = null)
Parameters
daprClientDaprClientcomponentsDaprComponentOptionsregistryTopicDaprSubscriptionRegistryloggerILogger<PubsubService>topicsTopicCataloghistoryIConsumerGroupPositionerreplayPubsubReplayOptionsbatchPubsubBatchOptionsprogressConsumerProgress
Methods
ChangePublicationFence(ChangePublicationFenceRequest, ServerCallContext)
Compare-and-swap publication ownership. Tokens are opaque activation IDs. A fresh new_token claims (expected_token current, fence inactive, or its lease expired); new_token == expected_token renews or revokes (holder only). Any lease holder may use it, e.g. the WorkManager Runtime's activation lease, keyed by worker id; connection_id is the holder's UUID.
public override Task<ChangePublicationFenceResponse> ChangePublicationFence(ChangePublicationFenceRequest request, ServerCallContext context)
Parameters
requestChangePublicationFenceRequestThe request received from the client.
contextServerCallContextThe context of the server-side call handler being invoked.
Returns
- Task<ChangePublicationFenceResponse>
The response to send back to the client (wrapped by a task).
ListTopics(ListTopicsRequest, ServerCallContext)
The topics seen at the gateway -- see TopicCatalog.
public override Task<ListTopicsResponse> ListTopics(ListTopicsRequest request, ServerCallContext context)
Parameters
requestListTopicsRequestcontextServerCallContext
Returns
- Task<ListTopicsResponse>
PublishEvent(PublishRequest, ServerCallContext)
public override Task<PublishResponse> PublishEvent(PublishRequest request, ServerCallContext context)
Parameters
requestPublishRequestcontextServerCallContext
Returns
- Task<PublishResponse>
PublishEvents(PublishEventsRequest, ServerCallContext)
Publishes a batch: each topic's events in the given order, different topics
in parallel. A topic's events are stored as batch entries
(Virtufin.Api.Services.PubsubBatchEntry): one stream entry, and so one sidecar round
trip, for up to MaxEvents events instead of
one each, written one after another. Subscribers receive the single events,
or the entry whole when they asked for it (accept_batches).
Not Dapr's bulk publish, which on Redis Streams publishes a batch's events in
parallel with no ordering guarantee. Every event is validated before any is
published; the events of an entry that could not be written all count as
failed.
public override Task<PublishEventsResponse> PublishEvents(PublishEventsRequest request, ServerCallContext context)
Parameters
requestPublishEventsRequestcontextServerCallContext
Returns
- Task<PublishEventsResponse>
ReportProgress(ReportProgressRequest, ServerCallContext)
Consumers' positions (openspec paced-publishing): applied on this pod at once and published once on the progress topic, from which every pod applies them (ConsumerProgressListener).
public override Task<ReportProgressResponse> ReportProgress(ReportProgressRequest request, ServerCallContext context)
Parameters
requestReportProgressRequestcontextServerCallContext
Returns
- Task<ReportProgressResponse>
Subscribe(SubscribeRequest, IServerStreamWriter<SubscribeResponse>, ServerCallContext)
Subscribe to one or more Dapr topics. Each topic joins the process's shared Dapr subscription for it (see TopicDaprSubscriptionRegistry); all messages are multiplexed into a single response stream.
public override Task Subscribe(SubscribeRequest request, IServerStreamWriter<SubscribeResponse> responseStream, ServerCallContext context)
Parameters
requestSubscribeRequestresponseStreamIServerStreamWriter<SubscribeResponse>contextServerCallContext