Table of Contents

Class PubsubService

Namespace
Virtufin.Api.Services
Assembly
Virtufin.Api.dll

Implements the Pubsub gRPC service for publish/subscribe messaging via Dapr. Publish receives a CloudEvent proto; Subscribe streams reconstructed CloudEvents.

public class PubsubService : Pubsub.PubsubBase
Inheritance
Pubsub.PubsubBase
PubsubService
Inherited Members

Constructors

PubsubService(DaprClient, DaprComponentOptions, PubsubSubscriptionManager, TopicDaprSubscriptionRegistry, ILogger<PubsubService>)

public PubsubService(DaprClient daprClient, DaprComponentOptions components, PubsubSubscriptionManager subscriptionManager, TopicDaprSubscriptionRegistry registry, ILogger<PubsubService> logger)

Parameters

daprClient DaprClient
components DaprComponentOptions
subscriptionManager PubsubSubscriptionManager
registry TopicDaprSubscriptionRegistry
logger ILogger<PubsubService>

Methods

PublishEvent(PublishRequest, ServerCallContext)

public override Task<PublishResponse> PublishEvent(PublishRequest request, ServerCallContext context)

Parameters

request PublishRequest
context ServerCallContext

Returns

Task<PublishResponse>

Subscribe(SubscribeRequest, IServerStreamWriter<SubscribeResponse>, ServerCallContext)

Subscribe to one or more Dapr topics. Each topic gets its own Dapr subscription; all messages are multiplexed into a single response stream.

public override Task Subscribe(SubscribeRequest request, IServerStreamWriter<SubscribeResponse> responseStream, ServerCallContext context)

Parameters

request SubscribeRequest
responseStream IServerStreamWriter<SubscribeResponse>
context ServerCallContext

Returns

Task

Unsubscribe(UnsubscribeRequest, ServerCallContext)

Removes an in-process subscriber by id.

public override Task<UnsubscribeResponse> Unsubscribe(UnsubscribeRequest request, ServerCallContext context)

Parameters

request UnsubscribeRequest
context ServerCallContext

Returns

Task<UnsubscribeResponse>

Remarks

Cancelling the Subscribe call is the supported teardown, not this RPC. Subscription ids are minted server-side and never sent to the client -- SubscribeResponse has no id field -- so there is no way for a caller to obtain a valid one. This RPC also only drops the in-process subscriber: it does not release the shared Dapr subscription's refcount and does not end the server-side stream, which keeps running against a channel nothing feeds.

It previously reported success for any string, including ids that matched nothing, which made a no-op indistinguishable from a real unsubscribe. It now says which happened.