use of com.hotels.styx.api.configuration.Configuration in project styx by ExpediaGroup.
the class StyxServerTest method styxConfig.
private static StyxConfig styxConfig() {
ProxyServerConfig proxyConfig = new ProxyServerConfig.Builder().setHttpConnector(new HttpConnectorConfig(0)).build();
AdminServerConfig adminConfig = new AdminServerConfig.Builder().setHttpConnector(new HttpConnectorConfig(0)).build();
Configuration config = new MapBackedConfiguration(EMPTY_CONFIGURATION).set("admin", adminConfig).set("proxy", proxyConfig);
return new StyxConfig(config);
}
use of com.hotels.styx.api.configuration.Configuration in project styx by ExpediaGroup.
the class ServiceProvision method servicesMap.
private static <U> Map<String, U> servicesMap(JsonNode jsonNode, Environment environment, Class<? extends U> serviceClass) {
JsonNode factories = jsonNode.get("factories");
JsonNodeConfig jsonNodeConfig = new JsonNodeConfig(factories);
return iteratorToList(factories.fieldNames()).stream().flatMap(name -> {
if (isType(name, jsonNodeConfig, SpiExtension.class)) {
return namedExtensionFromSpiExtension(environment, serviceClass, jsonNodeConfig, name);
} else if (isType(name, jsonNodeConfig, ServiceFactoryConfig.class)) {
return namedExtensionFromServiceFactoryConfig(environment, serviceClass, jsonNodeConfig, name);
} else {
String content = factories.get(name).toString();
String message = format("Unexpected configuration object 'services.factories.%s', Configuration='%s'", name, content);
throw new ConfigurationException(message);
}
}).collect(toMap(Pair::key, Pair::value));
}
use of com.hotels.styx.api.configuration.Configuration in project styx by ExpediaGroup.
the class StyxServerComponentsTest method createsEnvironment.
@Test
public void createsEnvironment() {
Configuration config = new Configuration.MapBackedConfiguration().set("foo", "abc").set("bar", "def");
StyxServerComponents components = new StyxServerComponents.Builder().registry(new MicrometerRegistry(new CompositeMeterRegistry())).styxConfig(new StyxConfig(config)).build();
Environment environment = components.environment();
assertThat(environment.configuration().get("foo", String.class), isValue("abc"));
assertThat(environment.configuration().get("bar", String.class), isValue("def"));
assertThat(environment.eventBus(), is(notNullValue()));
assertThat(environment.metricRegistry(), is(notNullValue()));
}
Aggregations