Table of Contents

Namespace Virtufin.WebSocketManager.Services

Classes

ApiLifecyclePublisher

Publishes connection lifecycle events to the virtufin-api's system-events topic. Events are CloudEvents v1.0 envelopes with the WSM's URN as the source. The publisher is best-effort: failures are logged but never propagated, so an unreachable API does not break the WSM's local connection state machine.

ConnectionNotFoundException
ConnectionOwnershipException
ConnectionReclaimerHostedService

Background service that periodically reclaims connections from dead instances. Prevents connection orphaning when pods are replaced via rolling update.

DaprCircuitBreakerHealthCheck

Health check that reports Dapr circuit breaker state.

DaprConnectionRepository

Implementation of IDaprConnectionRepository using Dapr state store.

DaprPublisher
DaprResiliencePipeline

Provides resilience policies for Dapr operations with retry and circuit breaker.

DaprStateStoreEntry

Represents a WebSocket connection entry stored in Dapr state store.

DefaultInstanceIdProvider

Default implementation of IInstanceIdProvider. Uses the HOSTNAME environment variable (Kubernetes pod name) for the instance ID. Falls back to a generated GUID if no HOSTNAME is set.

DistributedWebSocketConnectionStore

Distributed implementation of IWebSocketConnectionStore that uses Dapr state store for persistence.

InstanceHeartbeat

Persistent heartbeat record stored at websocketmanager/instances/<instance-id>.

InstanceHeartbeatService

Background service that publishes a heartbeat for this instance to the Dapr state store on a configured interval and discovers peer instance heartbeats to populate the local knownInstances set.

Without this, ConnectionReclaimerHostedService treats every connection from a different instance ID as a candidate for reclamation — which is correct only after the peer has died. Heartbeats let live peers advertise their presence so live connections are never reclaimed.

MessageSendException
MessageTimeoutException
WebSocketClientWrapper
WebSocketNotConnectedException
WebSocketService

Interfaces

IDaprConnectionRepository

Repository for persisting WebSocket connections to Dapr state store.

IDaprPublisher
IInstanceIdProvider

Provides the unique identifier for this service instance.

IWebSocketClientWrapper
IWebSocketConnectionStore

Interface for WebSocket connection storage.

IWebSocketService