public interface RatpackConsulConfig
ByteSource
to be used
with the existing ServerConfigBuilder
parsing options.Modifier and Type | Method and Description |
---|---|
static ByteSource |
value(String key)
Read the specified key as a
ByteSource using the default Consul agent connection properties. |
static ByteSource |
value(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 ByteSource |
value(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 ByteSource |
value(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 ByteSource value(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 ByteSource value(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 ByteSource value(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 ByteSource value(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