Skip to content

Transport API

dcc_mcp_core.TransportManager

TransportManager

Python-facing wrapper for the Rust transport layer. Bridges async operations to synchronous calls via an internal Tokio runtime.

Constructor

python
TransportManager(
    registry_dir: str,
    max_connections_per_dcc: int = 10,
    idle_timeout: int = 300,
    heartbeat_interval: int = 5,
    connect_timeout: int = 10,
    reconnect_max_retries: int = 3,
)

Service Discovery

MethodReturnsDescription
register_service(dcc_type, host, port, version=None, scene=None, metadata=None)strRegister a service, returns instance_id (UUID)
deregister_service(dcc_type, instance_id)boolDeregister a service by key
list_instances(dcc_type)List[dict]List all instances for a DCC type
list_all_services()List[dict]List all registered services
heartbeat(dcc_type, instance_id)boolUpdate heartbeat timestamp

Session Management

MethodReturnsDescription
get_or_create_session(dcc_type, instance_id=None)strGet/create a session (UUID). If no instance_id, picks first available
get_session(session_id)dict?Get session info dict, or None
record_success(session_id, latency_ms)Record successful request
record_error(session_id, latency_ms, error)Record failed request
begin_reconnect(session_id)intBegin reconnection, returns backoff in ms
reconnect_success(session_id)Mark reconnection as successful
close_session(session_id)boolClose a session
list_sessions()List[dict]List all active sessions
session_count()intNumber of active sessions

Connection Pool

MethodReturnsDescription
acquire_connection(dcc_type, instance_id=None)strAcquire connection (UUID)
release_connection(dcc_type, instance_id)Release connection back to pool
pool_size()intTotal connections in pool

Lifecycle

MethodReturnsDescription
cleanup()(int, int, int)Returns (stale_services, closed_sessions, evicted_connections)
shutdown()Graceful shutdown
is_shutdown()boolCheck if transport is shut down

Dunder Methods

MethodDescription
__repr__TransportManager(services=N, sessions=N, pool=N)
__len__Returns session count

Rust-Only Types

The following types are available in Rust but not directly exposed to Python:

TransportConfig

FieldTypeDefault
poolPoolConfig
sessionSessionConfig
connect_timeoutDuration10s
heartbeat_intervalDuration5s

PoolConfig

FieldTypeDefault
max_connections_per_typeusize10
max_idle_timeDuration300s
max_lifetimeDuration3600s
acquire_timeoutDuration30s

SessionConfig

FieldTypeDefault
idle_timeoutDuration300s
reconnect_max_retriesu323
reconnect_backoff_baseDuration1s
max_session_lifetimeDuration3600s
heartbeat_intervalDuration5s

TransportError

VariantDescription
ConnectionFailedTCP connection failed
ConnectionTimeoutConnection timed out
PoolExhaustedAll connections in use
AcquireTimeoutTimeout waiting for pooled connection
ServiceNotFoundService not in registry
ServiceAlreadyRegisteredDuplicate registration
SerializationMessagePack serialization error
IoIO error
RegistryFileRegistry file error
ShutdownTransport is shut down
SessionNotFoundSession not found
InvalidSessionStateInvalid state transition
ReconnectionFailedMax retries exceeded
InternalGeneric internal error

ServiceStatus

ValueDescription
AvailableAccepting connections (default)
BusyProcessing a request
UnreachableHealth check failed
ShuttingDownShutting down

SessionState

ValueDescription
ConnectedReady for requests
IdleIdle timeout exceeded
ReconnectingReconnecting after failure
ClosedTerminal state

Wire Protocol

Messages use MessagePack serialization with a 4-byte big-endian length prefix:

[4-byte length][MessagePack payload]
  • Request: { id: UUID, method: String, params: Vec<u8> }
  • Response: { id: UUID, success: bool, payload: Vec<u8>, error: Option<String> }

Released under the MIT License.