55 lines
2.2 KiB
Python
55 lines
2.2 KiB
Python
from os import environ
|
|
|
|
|
|
def read_from_environment(environment_variable_name, default_value):
|
|
return environ.get(environment_variable_name, default_value)
|
|
|
|
|
|
class Config(object):
|
|
def __init__(self):
|
|
# Logging level for service logger
|
|
self.logging_level_root = read_from_environment("LOGGING_LEVEL_ROOT", "DEBUG")
|
|
|
|
# RabbitMQ host address
|
|
self.rabbitmq_host = read_from_environment("RABBITMQ_HOST", "localhost")
|
|
|
|
# RabbitMQ host port
|
|
self.rabbitmq_port = read_from_environment("RABBITMQ_PORT", "5672")
|
|
|
|
# RabbitMQ username
|
|
self.rabbitmq_username = read_from_environment("RABBITMQ_USERNAME", "user")
|
|
|
|
# RabbitMQ password
|
|
self.rabbitmq_password = read_from_environment("RABBITMQ_PASSWORD", "bitnami")
|
|
|
|
# Controls AMQP heartbeat timeout in seconds
|
|
self.rabbitmq_heartbeat = read_from_environment("RABBITMQ_HEARTBEAT", "7200")
|
|
|
|
# Queue name for requests to the service
|
|
self.request_queue = read_from_environment("REQUEST_QUEUE", "request_queue")
|
|
|
|
# Queue name for responses by service
|
|
self.response_queue = read_from_environment("RESPONSE_QUEUE", "response_queue")
|
|
|
|
# Queue name for failed messages
|
|
self.dead_letter_queue = read_from_environment("DEAD_LETTER_QUEUE", "dead_letter_queue")
|
|
|
|
# The type of storage to use {s3, azure}
|
|
self.storage_backend = read_from_environment("STORAGE_BACKEND", "s3")
|
|
|
|
# The bucket / container to pull files specified in queue requests from
|
|
self.storage_bucket = read_from_environment("STORAGE_BUCKET", "pyinfra-test-bucket")
|
|
|
|
# Endpoint for s3 storage
|
|
self.storage_endpoint = read_from_environment("STORAGE_ENDPOINT", "http://127.0.0.1:9000")
|
|
|
|
# User for s3 storage
|
|
self.storage_key = read_from_environment("STORAGE_KEY", "root")
|
|
|
|
# Password for s3 storage
|
|
self.storage_secret = read_from_environment("STORAGE_SECRET", "password")
|
|
|
|
# Connection string for Azure storage
|
|
self.storage_azureconnectionstring = read_from_environment("STORAGE_AZURECONNECTIONSTRING",
|
|
"DefaultEndpointsProtocol=...")
|