Skip to content

WIP: Loading V2 #193

Open
Open
@rbygrave

Description

@rbygrave

Loaders / ConfigLoader2

  1. Each loader has a unique "prefix"
  2. There are builtin core loaders such as classpath file cmd stdin
  3. There are additional loaders like aws and vault etc that are registered via service loading

Flags

The known flags we want to support are:

NOT_REQUIRED
NO_INTERPOLATION

Note: maybe: prefix has been used as a synonym for NOT_REQUIRED.

Raw source expressions

Examples of <raw source expression>s

classpath:foo.properties
classpath:some/other.yaml
maybe:classpath:application-test.properties
file:${user.home}/config/myapp.properties
file:/app/config/myapp.yaml
file:./relative/myapp.yaml
cmd:-P
cmd
stdin
aws:aws.appconfig
aws
vault:myvault.prefix

Bootstrap

  1. classpath:avaje-config.properties [or avaje-config.yaml?]
  2. This is loaded as raw Key Values
  3. Process the avaje.load.sources

Process the avaje.load.sources

  1. Remove avaje.load.sources value. Delimited list of "load source keys" or "known source plugins". Delimited by space or comma.
  2. Remove avaje.load.prefix value. Defaults to _load_.
  3. Remove avaje.flags.prefix value. Defaults to _flags_.
  4. Split the avaje.load.sources into an ordered list of "load source key"s
  5. For each "load source key"
    5.1. Remove the _load_<source key> value [with default of <source key>] produces a <raw source expression>
    5.2. Remove the _flags_<source key> value produces a <set of flags>
    5.3. At this point we have an order list of <raw source expression> + set of flags
  6. Run interpolation of the remaining key values
  7. Add these interpolated key values to the context
  8. For each <raw source expression> + set of flags
    8.1. "perform a load for a source"
    8.2. Note that this can be recursive depth first traversal

Perform a load for a source

  1. Translate a maybe: prefix into a NOT_REQUIRED flag
  2. Determine the prefix which identifies the ConfigLoader2 to use
  3. Determine the optional path [remainder after the prefix is removed]
  4. Perform interpolation on the optional path
  5. ConfigLoader2.load() returning the KeyValues2 for this source. If "required" and source was not found throw exception
  6. Process the avaje.load.sources on the returned KeyValues2
  7. If "interpolation" flag then execute interpolation on the KeyValues2

Example avaje-config.properties

## specify load order including test
avaje.load.sources=foo bar cmd test aws vault
avaje.load.prefix=_load_
avaje.flags.prefix=_flags_

_load_test=maybe:classpath:application-test.properties

_load_foo=classpath:foo-repository-layer.properties classpath:foo-service-layer.properties.
_load_bar=classpath:bar-repository-layer.properties classpath:bar-service-layer.properties.

_load_cmd=cmd
_load_aws=aws  ## or aws:aws.appconfig
_load_vault=maybe:vault:myvault.prefix

aws.appconfig.region=${AWS_REGION}
aws.appconfig.appName=myapp
aws.appconfig.env=${ENV:local}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions