Skip to main content

CDKSettings

The CDKSettings class defines and loads configuration settings required to initialize and run a connector instance in the CDK (Connector Development Kit) environment. It provides both runtime environment selection (.env or .test.env) and a dynamic way to build the orchestrator's base URL.

Class Definition

class CDKSettings(BaseSettings):

Inherits from: BaseSettings
Defined in: core.config

The CDKSettings class holds all essential configuration variables for a connector, such as orchestrator address, security credentials, heartbeat settings, and runtime flags.

Constructor

def __init__(self, env_file: str):

Initializes the configuration from the specified environment file using the shared BaseSettings class.

Parameters

  • env_file (str): The name of the environment file (.env, .test.env, etc.)

Initializes

  • Configuration loading from specified environment file
  • Runtime environment selection and validation
  • Base settings inheritance and validation

Attributes

AttributeTypeDefaultDescription
secretstr""Authentication token or client key used by the connector
namestr""Optional name for the connector instance
orc_hoststr""Hostname or IP address of the orchestrator
orc_portint8080Port used to connect to the orchestrator
heartbeat_timeoutint20Interval (in seconds) between heartbeat messages
pool_sizeint30Size of the WebSocket connection pool
data_dirstr.connector_dataDirectory used to store connector-specific data
ssl_enabledint1Whether to use WSS (1) or WS (0) for communication

Public Methods

def base_url() -> str

Returns the full base URL used to establish a WebSocket connection with the orchestrator.

Logic

  • Uses wss:// if ssl_enabled is truthy.
  • Constructs the URL as:
<protocol>://<orc_host>:<orc_port>/orch

Returns: A string like wss://localhost:8080/orch or ws://127.0.0.1:8080/orch.

Global Configuration

cdk_settings

A singleton instance of CDKSettings, initialized automatically at import time.

Initialization Logic

if "TEST_ENV" in os.environ:
cdk_settings = CDKSettings(env_file=".test.env")
else:
cdk_settings = CDKSettings(env_file=".env")
  • If TEST_ENV is set in the environment, .test.env is used.
  • Otherwise, the default .env file is loaded.
def update_settings(s: CDKSettings) -> None

Updates the global cdk_settings instance with a new configuration.

Parameters

Dependencies

  • os: For environment variable detection
  • logger: Used to capture log messages during configuration loading
  • BaseSettings: Common configuration loader shared across the system (core.config.BaseSettings)