2021-02-15 17:11:39 +03:00
|
|
|
"""`Configuration` provider alias example."""
|
|
|
|
|
|
|
|
from dependency_injector import containers, providers
|
|
|
|
from environs import Env
|
|
|
|
|
|
|
|
|
|
|
|
class Container(containers.DeclarativeContainer):
|
|
|
|
|
|
|
|
config = providers.Configuration()
|
|
|
|
|
|
|
|
|
2021-09-30 22:32:21 +03:00
|
|
|
if __name__ == "__main__":
|
2021-02-15 17:11:39 +03:00
|
|
|
env = Env()
|
|
|
|
container = Container()
|
|
|
|
|
|
|
|
with container.config.some_plugin_name as plugin:
|
|
|
|
plugin.some_interval_ms.override(
|
|
|
|
env.int(
|
2021-09-30 22:32:21 +03:00
|
|
|
"SOME_INTERVAL_MS",
|
2021-02-15 17:11:39 +03:00
|
|
|
default=30000,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
with plugin.kafka as kafka:
|
|
|
|
kafka.bootstrap_servers.override(
|
|
|
|
env.list(
|
2021-09-30 22:32:21 +03:00
|
|
|
"KAFKA_BOOTSTRAP_SERVERS",
|
|
|
|
default=["kafka1", "kafka2"],
|
2021-02-15 17:11:39 +03:00
|
|
|
),
|
|
|
|
)
|
|
|
|
kafka.security_protocol.override(
|
|
|
|
env.str(
|
2021-09-30 22:32:21 +03:00
|
|
|
"KAFKA_SECURITY_PROTOCOL",
|
|
|
|
default="SASL_SSL",
|
2021-02-15 17:11:39 +03:00
|
|
|
),
|
|
|
|
)
|