Table of Contents

Class TopicCatalog

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

The topics seen at the gateway, for Pubsub.ListTopics.

Dapr's pubsub API cannot list topics, and asking the broker would tie this to one component (Redis stream keys, Kafka metadata, ...). Every publish and subscribe in Virtufin passes through the gateway, so the gateway records the names itself, in one state-store record (TopicCatalogKey) written with the ETag-guarded operations of IPublicationStateStore.

Note(string, TopicUse) is on the publish path, so it only touches memory: each replica notes a topic at most once per RecordInterval per use, and TopicCatalogWriter merges what is pending into the record in one write. Entries unseen for Retention are dropped then. Per-run reply topics (rpc.<caller>.reply.<run_id>) are never recorded: each is used once, and they would bury the real topics.

public sealed class TopicCatalog
Inheritance
TopicCatalog
Inherited Members

Constructors

TopicCatalog(IPublicationStateStore, string?, TimeProvider?)

The topics seen at the gateway, for Pubsub.ListTopics.

Dapr's pubsub API cannot list topics, and asking the broker would tie this to one component (Redis stream keys, Kafka metadata, ...). Every publish and subscribe in Virtufin passes through the gateway, so the gateway records the names itself, in one state-store record (TopicCatalogKey) written with the ETag-guarded operations of IPublicationStateStore.

Note(string, TopicUse) is on the publish path, so it only touches memory: each replica notes a topic at most once per RecordInterval per use, and TopicCatalogWriter merges what is pending into the record in one write. Entries unseen for Retention are dropped then. Per-run reply topics (rpc.<caller>.reply.<run_id>) are never recorded: each is used once, and they would bury the real topics.

public TopicCatalog(IPublicationStateStore state, string? key = null, TimeProvider? time = null)

Parameters

state IPublicationStateStore
key string
time TimeProvider

Fields

RecordInterval

public static readonly TimeSpan RecordInterval

Field Value

TimeSpan

Retention

public static readonly TimeSpan Retention

Field Value

TimeSpan

Methods

FlushAsync(CancellationToken)

Merges the pending sightings into the record and drops entries older than Retention. On failure the sightings stay pending for the next flush.

public Task<IReadOnlyList<string>> FlushAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Returns

Task<IReadOnlyList<string>>

IsCatalogued(string)

True if Note(string, TopicUse) records topic.

public static bool IsCatalogued(string topic)

Parameters

topic string

Returns

bool

ListAsync(CancellationToken)

The recorded topics (plus this replica's pending ones), sorted by name.

public Task<IReadOnlyList<KeyValuePair<string, TopicSighting>>> ListAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Returns

Task<IReadOnlyList<KeyValuePair<string, TopicSighting>>>

Note(string, TopicUse)

Notes that topic was used; memory only, never throws.

public void Note(string topic, TopicUse use)

Parameters

topic string
use TopicUse