Table of Contents

Class TopicDaprSubscriptionRegistry

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

Manages one Dapr pubsub subscription per topic per API process, with a reference count of in-process gRPC callers sharing it.

Per the Pub/Sub Topics spec §Subscription Implementation Pattern: one Dapr subscription per topic per service process — NOT one per gRPC call. Per-call Dapr subscriptions would cause the same event to be load-balanced across callers instead of broadcast to each.

public sealed class TopicDaprSubscriptionRegistry : IAsyncDisposable
Inheritance
TopicDaprSubscriptionRegistry
Implements
Inherited Members

Constructors

TopicDaprSubscriptionRegistry(IServiceProvider, ILogger<TopicDaprSubscriptionRegistry>)

public TopicDaprSubscriptionRegistry(IServiceProvider serviceProvider, ILogger<TopicDaprSubscriptionRegistry> logger)

Parameters

serviceProvider IServiceProvider
logger ILogger<TopicDaprSubscriptionRegistry>

Methods

AcquireAsync(string, Func<TopicMessage, CancellationToken, Task<TopicResponseAction>>, Action, CancellationToken)

Returns a handle backed by either an existing Dapr subscription for the topic (refcount +1) or a freshly opened one. Disposing the handle releases the reference; when the last reference is released, the Dapr subscription is torn down.

public Task<TopicDaprSubscriptionRegistry.SubscriptionHandle> AcquireAsync(string topic, Func<TopicMessage, CancellationToken, Task<TopicResponseAction>> onMessage, Action onActive, CancellationToken ct)

Parameters

topic string
onMessage Func<TopicMessage, CancellationToken, Task<TopicResponseAction>>
onActive Action
ct CancellationToken

Returns

Task<TopicDaprSubscriptionRegistry.SubscriptionHandle>

DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

public ValueTask DisposeAsync()

Returns

ValueTask

A task that represents the asynchronous dispose operation.