Skip to content

Commit 4f8771d

Browse files
committed
Support per-plugin config sections in the config file
1 parent 34713a4 commit 4f8771d

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

receptor/config.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ def __init__(self, args=None):
204204
key='delay',
205205
default_value=0,
206206
value_type='float',
207-
hint='The delay (in seconds) to wait between pings. If unspecified here or in a config file pings will be sent as soon as the previous response is received.',
207+
hint='The delay (in seconds) to wait between pings. If unspecified here or in a'
208+
'config file pings will be sent as soon as the previous response is received.',
208209
)
209210
self.add_config_option(
210211
section='ping',
@@ -368,6 +369,11 @@ def parse_options(self, args):
368369
# because env variables and configparser do not enforce the
369370
# value type, we do it now to ensure we have the type we want
370371
self._enforce_entry_type(entry)
372+
# Parse plugin_ sections to populate plugin configuration
373+
self._config_options['plugins'] = {}
374+
if self._config_file:
375+
for section in filter(lambda x: x.startswith("plugin_"), self._config_file.sections()):
376+
self._config_options['plugins'][section.replace("plugin_", "")] = dict(self._config_file[section])
371377

372378
def _enforce_entry_type(self, entry):
373379
if entry.value is not None:

receptor/protocol.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,4 +223,3 @@ def _data_received_callback(self, inner_env, fut):
223223
code=1,
224224
)
225225
self.emit_response(err_resp)
226-

receptor/work.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ async def handle(self, inner_env):
4848
logger.exception(f'Could not load action {action} from {namespace}')
4949
raise exceptions.InvalidDirectiveAction(f'Invalid action {action} for {namespace}')
5050
self.add_work(inner_env)
51-
responses = action_method(inner_env)
51+
responses = action_method(inner_env, self.receptor.config.plugins.get("namespace", {}))
5252
async for response in responses:
5353
serial += 1
5454
logger.debug(f'Response emitted for {inner_env.message_id}, serial {serial}')

0 commit comments

Comments
 (0)