Skip to content

Refactor run command #148

@mostafa

Description

@mostafa

The run command body has grown too big, so it'd be better to chop it up into separate (utility) functions or so, so as to make it more robust and extensible. This refactoring should help with multi-config non-default directives. That are two approaches we can take:

  1. Consider using the default config there's no other config directive defined.
  2. Consider default config a separate config entry and load the configuration alongside other directives.

I am more inclined towards the first options, as it seems more logical. The resulting config would look like this:

# first example
loggers:
  default:
    ...
  postgres:
    ...
  mongo:
    ...

clients:
  default:
    ...
  postgres:
    ...
  mongo:
    ...

pools:
  default:
    ...
  postgres:
    ...
  mongo:
    ...

proxy:
  default:
    ...
  postgres:
    ...
  mongo:
    ...

server:
  default:
    ...
  postgres:
    ...
  mongo:
    ...

metrics:
  default:
    ...
  postgres:
    ...
  mongo:
    ...

This causes lots of duplication, but there can be one rule to fix it: if there's only a default directive for each top-level directive, it will be used for all the others. That is, if there is just one default logger, it'll be shared by all the servers, clients and other directives.

Related: #83.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

Status

🎉 Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions