Skip to content

Gateway Election API

Generic gateway failover election for any DCC MCP server.

When the current gateway instance becomes unreachable, non-gateway instances automatically run a first-wins election to take over and maintain service availability.

Exported symbols: DccGatewayElection

DccGatewayElection

Constructor

ParameterTypeDefaultDescription
dcc_namestr(required)Short DCC identifier for log messages
serverAny(required)DCC server instance
gateway_hoststr"127.0.0.1"Gateway bind address
gateway_portint9765Gateway port to compete for
probe_intervalint5Seconds between health probes
probe_timeoutfloat2.0Timeout per probe in seconds
probe_failuresint3Consecutive failures before election
on_promotecallable | NoneNoneCallback invoked after winning election

Properties

PropertyTypeDescription
is_runningboolWhether the election thread is active
consecutive_failuresintCurrent consecutive gateway probe failure count

Methods

MethodReturnsDescription
start()NoneStart the background election thread
stop()NoneGracefully stop the election thread
get_status()dictReturn {running, consecutive_failures, gateway_host, gateway_port}

Environment Variables

VariableDefaultDescription
DCC_MCP_GATEWAY_PROBE_INTERVAL5Seconds between health probes
DCC_MCP_GATEWAY_PROBE_TIMEOUT2Timeout per probe in seconds
DCC_MCP_GATEWAY_PROBE_FAILURES3Consecutive failures before election
python
from dcc_mcp_core import DccGatewayElection

election = DccGatewayElection(dcc_name="blender", server=blender_server)
election.start()
# ... runs in background ...
election.stop()

Released under the MIT License.