Table of Contents

Class GatewaySubscriptionManager

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

In-process broadcast broker for the Gateway.Subscribe RPC. One broker per topic; multiple gRPC callers on the same topic all receive every message via BroadcastToTopicAsync(string, string, string, string, string, string, byte[], string, string, string).

public class GatewaySubscriptionManager : SubscriptionManagerBase<SubscribeResponse, GatewaySubscription>
Inheritance
GatewaySubscriptionManager
Inherited Members

Remarks

Per the Pub/Sub Topics spec §Subscription Implementation Pattern: one Dapr subscription per topic per API process (managed by TopicDaprSubscriptionRegistry); this class fans out to multiple in-process gRPC callers. The caller-side envelope is SubscribeResponse (CloudEvent proto envelope), in contrast to PubsubSubscriptionManager which also uses the SubscribeResponse envelope.

Constructors

GatewaySubscriptionManager(ILogger<GatewaySubscriptionManager>)

public GatewaySubscriptionManager(ILogger<GatewaySubscriptionManager> logger)

Parameters

logger ILogger<GatewaySubscriptionManager>

Methods

BroadcastToTopicAsync(string, string, string, string, string, string, byte[], string, string, string)

Broadcasts a parsed CloudEvent envelope to all in-process gRPC subscribers on the topic. The Dapr message handler in GatewayService.Subscribe calls this once per received Dapr message.

public Task BroadcastToTopicAsync(string topic, string id, string source, string type, string specVersion, string dataContentType, byte[] data, string pubsubTopic, string pubsubName, string path)

Parameters

topic string
id string
source string
type string
specVersion string
dataContentType string
data byte[]
pubsubTopic string
pubsubName string
path string

Returns

Task

GetIdleTimeout(GatewaySubscription)

Gets the idle timeout for a subscription.

protected override TimeSpan GetIdleTimeout(GatewaySubscription subscription)

Parameters

subscription GatewaySubscription

The subscription to get the timeout for.

Returns

TimeSpan

The idle timeout duration.

GetSubscriptionKey(GatewaySubscription)

Gets the subscription key for a subscription.

protected override string GetSubscriptionKey(GatewaySubscription subscription)

Parameters

subscription GatewaySubscription

The subscription to get the key for.

Returns

string

The subscription key string.

SendEventAsync(GatewaySubscription, SubscribeResponse, CancellationToken)

Sends an event to a subscription.

protected override Task SendEventAsync(GatewaySubscription subscription, SubscribeResponse evt, CancellationToken cancellationToken)

Parameters

subscription GatewaySubscription

The subscription to send to.

evt SubscribeResponse

The event to send.

cancellationToken CancellationToken

The cancellation token.

Returns

Task

Subscribe(string, ChannelWriter<SubscribeResponse>)

Subscribes to a topic. Returns a unique subscription ID. Each ID is a fresh GUID; pass it back to UnsubscribeById(string) when the gRPC call ends.

public string Subscribe(string topic, ChannelWriter<SubscribeResponse> writer)

Parameters

topic string
writer ChannelWriter<SubscribeResponse>

Returns

string

UnsubscribeById(string)

Removes a subscription by its ID. Iterates all topics.

public void UnsubscribeById(string subscriptionId)

Parameters

subscriptionId string