@Override protected void initAuthProvider(JsonObject auth) { // Recall super super.initAuthProvider(auth); // If auth provider not set, try env vars if (authProvider == null) { String username = container.env().get(ENV_VAR_USERNAME); String password = container.env().get(ENV_VAR_PASSWORD); if (!Strings.isNullOrEmpty(username) && !Strings.isNullOrEmpty(password)) { authProvider = new PlainTextAuthProvider(username, password); } } } }
@Override protected void initSeeds(JsonArray seeds) { // Recall super super.initSeeds(seeds); // If default, try env vars if (DEFAULT_SEEDS.equals(this.seeds)) { String envVarSeeds = container.env().get(ENV_VAR_SEEDS); if (!Strings.isNullOrEmpty(envVarSeeds)) { logger.debug("Using environment configuration of " + envVarSeeds); String[] seedsArray = envVarSeeds.split("\\|"); this.seeds = ImmutableList.copyOf(seedsArray); } } }
/** * Returns the current Vertx container environment. */ public static ArrayValue env(Env env) { Map<String, String> map = PhpVerticleFactory.container.env(); ArrayValue array = new ArrayValueImpl(); for (Map.Entry<String, String> entry : map.entrySet()) { array.append(env.createString(entry.getKey()), env.createString(entry.getValue())); } return array; }
@Override protected void initLoadBalancingPolicy(JsonObject loadBalancing) { // Recall super super.initLoadBalancingPolicy(loadBalancing); // If LB policy not set, try env vars if (loadBalancingPolicy == null) { String localDC = container.env().get(ENV_VAR_LOCAL_DC); if (!Strings.isNullOrEmpty(localDC)) { logger.debug("Using environment config for Local DC of " + localDC); loadBalancingPolicy = new DCAwareRoundRobinPolicy(localDC); } else { logger.debug("No environment configuration found for local DC"); } } }