CleverSwarm API invocation example
This commit is contained in:
@@ -1,8 +1,15 @@
|
||||
import configparser
|
||||
import os
|
||||
|
||||
"""
|
||||
Convert configuration from properties file to an object.
|
||||
"""
|
||||
|
||||
|
||||
class AMQAdapter:
|
||||
"""
|
||||
configuration with prefix 'cm.amq-adapter'
|
||||
"""
|
||||
|
||||
PREFIX: str = 'cm.amq-adapter.'
|
||||
|
||||
@@ -23,8 +30,10 @@ class AMQAdapter:
|
||||
return f"{self.service_name}-{self.generator_id}-"
|
||||
|
||||
|
||||
|
||||
class Dispatch:
|
||||
"""
|
||||
configuration with prefix 'cm.dispatch'
|
||||
"""
|
||||
|
||||
PREFIX: str = 'cm.dispatch.'
|
||||
|
||||
@@ -52,6 +61,9 @@ class Dispatch:
|
||||
|
||||
|
||||
class Backpressure:
|
||||
"""
|
||||
configuration with prefix 'cm.backpressure'
|
||||
"""
|
||||
|
||||
PREFIX: str = 'cm.backpressure.'
|
||||
|
||||
@@ -68,15 +80,28 @@ class Backpressure:
|
||||
self.time_window = config.getint('CleverMicro-AMQ', self.PREFIX + 'time-window', fallback=3000)
|
||||
|
||||
|
||||
class AMQConfiguration:
|
||||
DEFAULT_PROPERTIES_FILE = '/app/amqp/config/application.properties'
|
||||
|
||||
|
||||
class AMQConfiguration:
|
||||
"""
|
||||
Top level configuration context holder / object
|
||||
"""
|
||||
def __init__(self):
|
||||
config = configparser.ConfigParser()
|
||||
# Read the application.properties file
|
||||
if os.getenv('USER', 'linux') == 'stanhejny':
|
||||
config.read('../config/application.properties.local')
|
||||
if os.path.exists(DEFAULT_PROPERTIES_FILE):
|
||||
config.read(DEFAULT_PROPERTIES_FILE)
|
||||
else:
|
||||
config.read('/app/amqp/config/application.properties')
|
||||
config.read('../config/application.properties.local')
|
||||
|
||||
# Override values with environment variables
|
||||
for section in config.sections():
|
||||
for option in config.options(section):
|
||||
# env_var = f"{section.upper()}_{option.upper()}"
|
||||
if option in os.environ:
|
||||
config.set(section, option, os.environ[option])
|
||||
|
||||
#
|
||||
# Add individual config areas
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user