Package ratpack.consul
Interface RatpackConsulConfig
-
public interface RatpackConsulConfigIntegration for retrieving values from a Consul Key-Value store asByteSourceto be used with the existingServerConfigBuilderparsing options.- Since:
- 1.5
-
-
Method Summary
Static Methods Modifier and Type Method Description static com.google.common.io.ByteSourcevalue(String key)Read the specified key as aByteSourceusing the default Consul agent connection properties.static com.google.common.io.ByteSourcevalue(String key, com.orbitz.consul.option.QueryOptions queryOptions)Read the specified key as aByteSourceusing the default Consul agent connection properties and the providedQueryOptions.static com.google.common.io.ByteSourcevalue(String key, com.orbitz.consul.option.QueryOptions queryOptions, Action<? super com.orbitz.consul.Consul.Builder> clientConfig)Read the specified key as aByteSourceusing the specified configuration to connection to Consul and the providedQueryOptions.static com.google.common.io.ByteSourcevalue(String key, Action<? super com.orbitz.consul.Consul.Builder> clientConfig)Read the specified key as aByteSourceusing the specified configuration to connection to Consul.
-
-
-
Method Detail
-
value
static com.google.common.io.ByteSource value(String key)
Read the specified key as aByteSourceusing the default Consul agent connection properties.- Parameters:
key- the key to read from Consul's Key-Value store- Returns:
- a
ByteSourcerepresenting the value stored in the key - See Also:
value(String, QueryOptions, Action)
-
value
static com.google.common.io.ByteSource value(String key, com.orbitz.consul.option.QueryOptions queryOptions)
Read the specified key as aByteSourceusing the default Consul agent connection properties and the providedQueryOptions.- Parameters:
key- the key to read from Consul Key-Value storequeryOptions- the options to use when querying Consul- Returns:
- a
ByteSourcerepresenting the value stored in the key - See Also:
value(String, QueryOptions, Action)
-
value
static com.google.common.io.ByteSource value(String key, Action<? super com.orbitz.consul.Consul.Builder> clientConfig)
Read the specified key as aByteSourceusing the specified configuration to connection to Consul.- Parameters:
key- the key to read from Consul's KeyValue storeclientConfig- the configuration for the Consul connection- Returns:
- a
ByteSourcerepresenting the value stored in the key - See Also:
value(String, QueryOptions, Action)
-
value
static com.google.common.io.ByteSource value(String key, com.orbitz.consul.option.QueryOptions queryOptions, Action<? super com.orbitz.consul.Consul.Builder> clientConfig)
Read the specified key as aByteSourceusing the specified configuration to connection to Consul and the providedQueryOptions. The returned value can then be passed to the existing parsing options inServerConfigBuilderto 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))) ) ); } }- Parameters:
key- the key to read from Consul Key-Value storequeryOptions- the options to use when querying ConsulclientConfig- he configuration for the Consul connection- Returns:
- a
ByteSourcerepresenting the value stored in the key
-
-