Skip to content

Commit

Permalink
fix(config): config implemnetation errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
shahinism committed Aug 28, 2024
1 parent 5249702 commit a62ac11
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 60 deletions.
3 changes: 2 additions & 1 deletion devenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
enable = true;
requirements = ''
pdm
python-lsp-server
python-lsp-server[all]
pylint
importmagic
epc
black
Expand Down
62 changes: 3 additions & 59 deletions src/sparkle/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,63 +1,7 @@
from dataclasses import dataclass
from typing import Any


@dataclass(frozen=True)
class TableConfig:
"""Hive Table Configuration."""

bucket: str
table: str


@dataclass(frozen=True)
class Credentials:
"""Credentials convention to use for any external services.
Args:
username (str): Username.
password (str): Password.
Note: the password is stored as a string. Don't log it.
"""

username: str | None
password: str | None


@dataclass(frozen=True)
class SchemaRegistryConfig:
"""Schema Registry Configuration."""

url: str
credentials: Credentials


@dataclass
class KafkaConfig(frozen=True):
"""Kafka Configuration."""

bootstrap_servers: str
credentials: Credentials
checkpoints_bucket: str
starting_offset: str = "earliest"
auth_protocol: str = "SASL_SSL"
auth_mechanism: str = "PLAIN"
schema_registry: SchemaRegistryConfig | None


@dataclass(frozen=True)
class IcebergConfig:
"""Iceberg Configuration."""

compact: bool = True
expire_snapshots: bool = True
rewrite_manifest: bool = True
compaction_strategy: str = "binpack"
compaction_options: dict[str, Any] | None = None
sort_order: str | None = None
snapshot_max_age_days: int = 14
min_snapshots: int = 50
from .kafka_config import KafkaConfig
from .iceberg_config import IcebergConfig
from .database_config import TableConfig


@dataclass(frozen=True)
Expand Down
9 changes: 9 additions & 0 deletions src/sparkle/config/database_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from dataclasses import dataclass


@dataclass(frozen=True)
class TableConfig:
"""Hive Table Configuration."""

bucket: str
table: str
16 changes: 16 additions & 0 deletions src/sparkle/config/iceberg_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from dataclasses import dataclass
from typing import Any


@dataclass(frozen=True)
class IcebergConfig:
"""Iceberg Configuration."""

compact: bool = True
expire_snapshots: bool = True
rewrite_manifest: bool = True
compaction_strategy: str = "binpack"
compaction_options: dict[str, Any] | None = None
sort_order: str | None = None
snapshot_max_age_days: int = 14
min_snapshots: int = 50
37 changes: 37 additions & 0 deletions src/sparkle/config/kafka_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from dataclasses import dataclass


@dataclass(frozen=True)
class Credentials:
"""Credentials convention to use for any external services.
Args:
username (str): Username.
password (str): Password.
Note: the password is stored as a string. Don't log it.
"""

username: str | None
password: str | None


@dataclass(frozen=True)
class SchemaRegistryConfig:
"""Schema Registry Configuration."""

url: str
credentials: Credentials


@dataclass
class KafkaConfig(frozen=True):
"""Kafka Configuration."""

bootstrap_servers: str
credentials: Credentials
checkpoints_bucket: str
starting_offset: str = "earliest"
auth_protocol: str = "SASL_SSL"
auth_mechanism: str = "PLAIN"
schema_registry: SchemaRegistryConfig | None

0 comments on commit a62ac11

Please sign in to comment.