graflo.connections.provider¶
Runtime resolution of conn_proxy labels to connection configs.
Manifests stay secret-free: a connector names a conn_proxy label in its
bindings, and a :class:ConnectionProvider maps each label to a
:data:~graflo.connections.sources.ConnConfig at run time. Which connector
uses which label is read from the bindings at lookup, never copied into the
provider.
Attributes¶
ConnConfig = PostgresConfig | SparqlEndpointConfig | RestApiConnConfig | KafkaConnConfig | FilesConnConfig
module-attribute
¶
A runtime connection a conn_proxy label resolves to.
__all__ = ['ApiAuth', 'ConnConfig', 'ConnectionProvider', 'EmptyConnectionProvider', 'FilesConnConfig', 'InMemoryConnectionProvider', 'KafkaConnConfig', 'RestApiConnConfig', 'S3ConnConfig', 'SparqlAuth', 'connector_config', 'proxy_env_prefix', 'resolve_db_secrets_from_env', 'resolve_secrets_from_env']
module-attribute
¶
Classes¶
ApiAuth
¶
Bases: BaseModel
Authentication payload for REST API source access.
Source code in graflo/connections/sources.py
Attributes¶
auth_type = 'bearer'
class-attribute
instance-attribute
¶
header_name = 'Authorization'
class-attribute
instance-attribute
¶
password = None
class-attribute
instance-attribute
¶
prefix = 'Bearer'
class-attribute
instance-attribute
¶
token = None
class-attribute
instance-attribute
¶
username = None
class-attribute
instance-attribute
¶
ConnectionProvider
¶
Bases: Protocol
Resolve a conn_proxy label to its runtime connection config.
Source code in graflo/connections/provider.py
EmptyConnectionProvider
¶
A provider with no configs: every label resolves to None.
Source code in graflo/connections/provider.py
FilesConnConfig
¶
Bases: BaseModel
A place files are read from: a local directory or an S3 bucket prefix.
root is an absolute local path, or s3://<bucket>[/<prefix>]. A
FileConnector bound to this connection reads sub_path relative to
the root. The S3 fields apply to an s3:// root only; keys come from
{PREFIX}ACCESS_KEY_ID / {PREFIX}SECRET_ACCESS_KEY at run time.
Source code in graflo/connections/sources.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | |
Attributes¶
access_key_id = None
class-attribute
instance-attribute
¶
alias = Field(default=None, description=_ALIAS_DESCRIPTION)
class-attribute
instance-attribute
¶
bucket
property
¶
The bucket of an s3:// root.
endpoint_url = Field(default=None, description='For S3-compatible endpoints (MinIO, SeaweedFS).')
class-attribute
instance-attribute
¶
is_s3
property
¶
kind = 'files'
class-attribute
instance-attribute
¶
local_root
property
¶
The directory of a local root.
prefix
property
¶
The key prefix of an s3:// root, without slashes at either end.
proxy_name = Field(default=None, description=_PROXY_NAME_DESCRIPTION)
class-attribute
instance-attribute
¶
region = None
class-attribute
instance-attribute
¶
root = Field(min_length=1)
class-attribute
instance-attribute
¶
secret_access_key = None
class-attribute
instance-attribute
¶
Methods:¶
from_env(env_prefix)
classmethod
¶
Load from {env_prefix}<FIELD>: ROOT is required, the rest optional.
Source code in graflo/connections/sources.py
s3_config()
¶
The boto3 settings of an s3:// root.
Source code in graflo/connections/sources.py
InMemoryConnectionProvider
¶
conn_proxy label → config, held in memory.
Build it from a mapping, InMemoryConnectionProvider({"shop_db": cfg}),
or from the environment with :meth:from_env.
Source code in graflo/connections/provider.py
Attributes¶
configs = dict(configs or {})
instance-attribute
¶
Methods:¶
__init__(configs=None)
¶
from_env(bindings, *, env_prefix_map=None)
classmethod
¶
One config per conn_proxy the bindings use, read from the environment.
The config type follows the connectors that name the label: table →
:class:PostgresConfig, SPARQL → :class:SparqlEndpointConfig, REST
API → :class:RestApiConnConfig, Kafka → :class:KafkaConnConfig,
file → :class:FilesConnConfig. Each reads {PREFIX}<FIELD>,
PREFIX from :func:proxy_env_prefix unless env_prefix_map names
one for the label. Labels named only by push connectors are skipped.
Raises:
| Type | Description |
|---|---|
ValueError
|
A label is named by connectors needing different config types, or a label's required variables are missing — every such label is listed in one error. |
Source code in graflo/connections/provider.py
get_config(conn_proxy)
¶
KafkaConnConfig
¶
Bases: BaseModel
Runtime Kafka broker connection settings (bootstrap and auth).
Source code in graflo/connections/sources.py
Attributes¶
alias = Field(default=None, description=_ALIAS_DESCRIPTION)
class-attribute
instance-attribute
¶
bootstrap_servers
instance-attribute
¶
client_id = None
class-attribute
instance-attribute
¶
kind = 'stream'
class-attribute
instance-attribute
¶
proxy_name = Field(default=None, description=_PROXY_NAME_DESCRIPTION)
class-attribute
instance-attribute
¶
sasl_mechanism = None
class-attribute
instance-attribute
¶
sasl_password = None
class-attribute
instance-attribute
¶
sasl_username = None
class-attribute
instance-attribute
¶
security_protocol = 'PLAINTEXT'
class-attribute
instance-attribute
¶
Methods:¶
from_env(env_prefix)
classmethod
¶
Load Kafka config from environment variables.
Supported variables (all prefixed with env_prefix):
BOOTSTRAP_SERVERS(required)SECURITY_PROTOCOL:PLAINTEXT,SASL_PLAINTEXT,SASL_SSL, orSSL(default:PLAINTEXT)CLIENT_IDSASL_MECHANISM,SASL_USERNAME,SASL_PASSWORD
Source code in graflo/connections/sources.py
to_consumer_config()
¶
Build a confluent-kafka consumer config dict from connection settings.
Source code in graflo/connections/sources.py
RestApiConnConfig
¶
Bases: BaseModel
Runtime REST API connection settings (base URL and credentials).
Source code in graflo/connections/sources.py
Attributes¶
alias = Field(default=None, description=_ALIAS_DESCRIPTION)
class-attribute
instance-attribute
¶
auth = None
class-attribute
instance-attribute
¶
base_url
instance-attribute
¶
default_headers = Field(default_factory=dict)
class-attribute
instance-attribute
¶
kind = 'api'
class-attribute
instance-attribute
¶
proxy_name = Field(default=None, description=_PROXY_NAME_DESCRIPTION)
class-attribute
instance-attribute
¶
Methods:¶
from_env(env_prefix)
classmethod
¶
Load REST API config from environment variables.
Supported variables (all prefixed with env_prefix):
BASE_URL(required)AUTH_TYPE:bearer,basic,digest, orapi_key(default:bearer)TOKEN,USERNAME,PASSWORDHEADER_NAME,PREFIX(bearer / api_key)
With none of TOKEN, USERNAME and PASSWORD set the API is
taken to be open: auth is None and no credential header is sent.
Source code in graflo/connections/sources.py
S3ConnConfig
¶
Bases: BaseModel
What a boto3 S3 client needs: endpoint, region and keys, plus a default bucket.
Not a registered connection on its own: a :class:FilesConnConfig with an
s3:// root produces one (:meth:FilesConnConfig.s3_config).
Source code in graflo/connections/sources.py
Attributes¶
aws_access_key_id = Field(default=None)
class-attribute
instance-attribute
¶
aws_secret_access_key = Field(default=None)
class-attribute
instance-attribute
¶
bucket = Field(default=None, description='Default bucket.')
class-attribute
instance-attribute
¶
endpoint_url = Field(default=None, description='For S3-compatible endpoints (MinIO, etc.).')
class-attribute
instance-attribute
¶
region = Field(default=None)
class-attribute
instance-attribute
¶
Methods:¶
from_env(env_prefix)
classmethod
¶
Load S3 config from {env_prefix}<FIELD> variables.
Reads BUCKET, REGION, AWS_ACCESS_KEY_ID,
AWS_SECRET_ACCESS_KEY and ENDPOINT_URL; all are optional.
Source code in graflo/connections/sources.py
SparqlAuth
¶
Bases: BaseModel
Authentication payload for SPARQL endpoint access.
Source code in graflo/connections/sources.py
Functions:¶
connector_config(connector, bindings, provider, expected)
¶
The config of connector's conn_proxy, checked to be an expected.
Raises:
| Type | Description |
|---|---|
ValueError
|
The connector has no |
Source code in graflo/connections/provider.py
proxy_env_prefix(conn_proxy)
¶
The environment-variable prefix of a conn_proxy label.
user_service → USER_SERVICE_; billing-api → BILLING_API_.
resolve_db_secrets_from_env(config, conn_proxy, env_prefix=None)
¶
Fill a stored database config's missing username and password from the environment.
The same rule as :func:resolve_secrets_from_env, for any database config,
a graph target included: {prefix}USERNAME / {prefix}PASSWORD fill
what config lacks and never override a stored value.
Returns:
| Type | Description |
|---|---|
_D
|
A copy of config with missing credentials filled, or config itself |
_D
|
when nothing was filled. |
Source code in graflo/connections/provider.py
resolve_secrets_from_env(config, conn_proxy, env_prefix=None)
¶
Fill a stored config's missing credentials from the environment.
A registry stores connections without secrets; the secret behind a
conn_proxy label arrives at run time, read from {prefix}<NAME>
where prefix defaults to :func:proxy_env_prefix:
- database and SPARQL:
USERNAME,PASSWORD; - REST API:
TOKEN,USERNAME,PASSWORD; - Kafka:
SASL_USERNAME,SASL_PASSWORD; - files on S3:
ACCESS_KEY_ID,SECRET_ACCESS_KEY.
A value already present on config is kept: the environment fills gaps and never overrides a stored setting.
Returns:
| Type | Description |
|---|---|
_C
|
A copy of config with missing credentials filled, or config itself |
_C
|
when nothing was filled. |