Class TopicCatalog
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
stateIPublicationStateStorekeystringtimeTimeProvider
Fields
RecordInterval
public static readonly TimeSpan RecordInterval
Field Value
Retention
public static readonly TimeSpan Retention
Field Value
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
cancellationTokenCancellationToken
Returns
IsCatalogued(string)
True if Note(string, TopicUse) records topic.
public static bool IsCatalogued(string topic)
Parameters
topicstring
Returns
ListAsync(CancellationToken)
The recorded topics (plus this replica's pending ones), sorted by name.
public Task<IReadOnlyList<KeyValuePair<string, TopicSighting>>> ListAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationToken
Returns
Note(string, TopicUse)
Notes that topic was used; memory only, never throws.
public void Note(string topic, TopicUse use)