Netflix / archaius

Library for configuration management API
Apache License 2.0
2.46k stars 485 forks source link

Archaius 0.x to Archaius 2 migration help request #500

Open Crystark opened 7 years ago

Crystark commented 7 years ago

Hi,

We've been working with Archaius 0.x for over 3 years now and have always been very pleased with it. We're starting a new project so I wanted to update archaius to the latest 2.x version.

However, the API seems to have changed ALOT and i'm really not sure how to adapt to this. First, I haven't been able to understand the new Archaius 2 approach for now. Second, I'm not sure if we can reproduce the same behavior we had with archaius 0.7.5.

Here's what we used:

At runtime we would use

java \
  -Darchaius.deployment.environment=dev \
  -Darchaius.configurationSource.additionalUrls=http://myhost/override.properties \
  -Darchaius.fixedDelayPollingScheduler.initialDelayMills=5000 \
  -Darchaius.fixedDelayPollingScheduler.delayMills=10000 \
  -jar my.jar

The code would the look like this:

private static DynamicPropertyFactory   I = DynamicPropertyFactory.getInstance();

static {
    try {
        ConfigurationManager.loadAppOverrideProperties("app");
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
        throw new RuntimeException(e);
    }
    String env = ConfigurationManager.getDeploymentContext().getDeploymentEnvironment();
    if (env == null) {
        String err = "You need to define -Darchaius.deployment.environment=env";
        logger.error(err);
        throw new RuntimeException(err);
    }
    else {
        logger.info("Environnement: " + env);
    }
}

public final DynamicStringProperty      name;

private MyConfig(String prefix, IConfig defaultConfig) {
    this.name = F.getStringProperty(prefix + "name", defaultConfig.getName());
}

We only use override properties cause that's what works for us. When we pull various project, we also initialized the override with the config from the new project (e.g. ConfigurationManager.loadAppOverrideProperties("app2") to load app2.properties)

What we would like to keep is:

Can anyone help me with this migration and point me in the right direction ?

I'm also interested in the guice intergration as we're also using it but that's secondary. Thanks

TheXs commented 4 years ago

Same problem here. Any comment?