public interface RatpackConsulConfig
ByteSource to be used
with the existing ServerConfigBuilder parsing options.| Modifier and Type | Method and Description |
|---|---|
static com.google.common.io.ByteSource |
value(java.lang.String key)
Read the specified key as a
ByteSource using the default Consul agent connection properties. |
static com.google.common.io.ByteSource |
value(java.lang.String key,
Action<? super com.orbitz.consul.Consul.Builder> clientConfig)
Read the specified key as a
ByteSource using the specified configuration to connection to Consul. |
static com.google.common.io.ByteSource |
value(java.lang.String key,
com.orbitz.consul.option.QueryOptions queryOptions)
Read the specified key as a
ByteSource using the default Consul agent connection properties and the provided QueryOptions. |
static com.google.common.io.ByteSource |
value(java.lang.String key,
com.orbitz.consul.option.QueryOptions queryOptions,
Action<? super com.orbitz.consul.Consul.Builder> clientConfig)
Read the specified key as a
ByteSource using the specified configuration to connection to Consul and the provided QueryOptions. |
static com.google.common.io.ByteSource value(java.lang.String key)
ByteSource using the default Consul agent connection properties.key - the key to read from Consul's Key-Value storeByteSource representing the value stored in the keyvalue(String, QueryOptions, Action)static com.google.common.io.ByteSource value(java.lang.String key,
com.orbitz.consul.option.QueryOptions queryOptions)
ByteSource using the default Consul agent connection properties and the provided QueryOptions.key - the key to read from Consul Key-Value storequeryOptions - the options to use when querying ConsulByteSource representing the value stored in the keyvalue(String, QueryOptions, Action)static com.google.common.io.ByteSource value(java.lang.String key,
Action<? super com.orbitz.consul.Consul.Builder> clientConfig)
ByteSource using the specified configuration to connection to Consul.key - the key to read from Consul's KeyValue storeclientConfig - the configuration for the Consul connectionByteSource representing the value stored in the keyvalue(String, QueryOptions, Action)static com.google.common.io.ByteSource value(java.lang.String key,
com.orbitz.consul.option.QueryOptions queryOptions,
Action<? super com.orbitz.consul.Consul.Builder> clientConfig)
ByteSource using the specified configuration to connection to Consul and the provided QueryOptions.
The returned value can then be passed to the existing parsing options in ServerConfigBuilder to provide configuration.
import ratpack.consul.RatpackConsulConfig;
import ratpack.test.embed.EmbeddedApp;
import com.orbitz.consul.option.ImmutableQueryOptions;
public class Example {
public static class Config {
public String name;
public String environment;
public String secret;
}
public static void main(String... args) throws Exception {
EmbeddedApp.of(a -> a
.serverConfig(s -> s
.yaml(RatpackConsulConfig.value("default/app"))
.json(RatpackConsulConfig.value("default/environment", ImmutableQueryOptions.builder().token("app-acl-token").build()))
.props(RatpackConsulConfig.value("app/environment", b -> b.withUrl("https://consul.domain.io")))
.require("/config", Config.class)
)
.handlers(c -> c
.get(ctx -> ctx.render(ctx.get(Config.class)))
)
);
}
}
key - the key to read from Consul Key-Value storequeryOptions - the options to use when querying ConsulclientConfig - he configuration for the Consul connectionByteSource representing the value stored in the key