Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type-safe configuration migration #37

Open
A248 opened this issue Aug 29, 2023 · 0 comments
Open

Type-safe configuration migration #37

A248 opened this issue Aug 29, 2023 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@A248
Copy link
Owner

A248 commented Aug 29, 2023

We should add easy-to-use migrations to DazzleConf. These allow users to migrate their configuration options from older values as new settings are added.

In particular, migrating one's configuration should be type safe. For example, suppose I have an interface Config. I want to add a new version, so I copy the interface and create two files, ConfigV1 and Config, where Config stands in for the new version of the configuration. DazzleConf should then allow me to write a simple converter:

public class MyMigrator implements ConfigurationMigrator<ConfigV1, Config> {

  public Config fromPrevious(ConfigV1 previous) {
    // Perform migration
  }
}

Detecting the configuration version could be accomplished in a few ways. We could simply attempt to read the configuration according to ConfigV1's definition, and if that fails, move on to the new version, Config. We could perform a differential calculation on the new definition versus the old definition, then use the unique aspects of each version for its detection, starting with newer versions as a fast-path. Or, less appealingly, developers might supply a configuration version as part of the config definition which is supposed to remain untouched by the end user.

This whole framework could even allow us to import from other configuration frameworks. For instance, maybe you wrote an encapsulation-destroying mess of public final fields whose values are loaded via reflection by a different configuration library. You'd still need to depend on the old library for deserializing the old instance, but at least you gain the benefits of DazzleConf going forward, and can stop depending on the old library eventually once end users have migrated.

@A248 A248 added the enhancement New feature or request label Aug 29, 2023
@A248 A248 added this to the 2.0.0 milestone Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant