use of com.hotels.styx.Environment in project styx by ExpediaGroup.
the class PluginLoadingForStartup method loadPlugin.
private static NamedPlugin loadPlugin(Environment environment, ConfiguredPluginFactory factory) {
PluginFactory.Environment pluginEnvironment = new PluginFactory.Environment() {
@Override
public <T> T pluginConfig(Class<T> clazz) {
return factory.pluginConfig(clazz);
}
@Override
public Configuration configuration() {
return environment.configuration();
}
@Override
public MeterRegistry pluginMeterRegistry() {
return environment.meterRegistry().scope("plugin.internal." + factory.name().toLowerCase());
}
@Override
@Deprecated
public MetricRegistry metricRegistry() {
return environment.metricRegistry().scope("plugin.internal." + factory.name());
}
};
Plugin plugin = factory.pluginFactory().create(pluginEnvironment);
return namedPlugin(factory.name(), plugin);
}
use of com.hotels.styx.Environment in project styx by ExpediaGroup.
the class StyxBackendServiceClientFactoryTest method setUp.
@BeforeEach
public void setUp() {
connectionFactory = mock(Connection.Factory.class);
environment = new Environment.Builder().registry(new MicrometerRegistry(new SimpleMeterRegistry())).build();
backendService = newBackendServiceBuilder().origins(newOriginBuilder("localhost", 8081).build()).build();
when(connectionFactory.createConnection(any(Origin.class), any(ConnectionSettings.class))).thenReturn(Mono.just(mock(Connection.class)));
}
use of com.hotels.styx.Environment in project styx by ExpediaGroup.
the class InterceptorPipelineBuilderTest method setUp.
@BeforeEach
public void setUp() {
environment = new Environment.Builder().registry(new MicrometerRegistry(new SimpleMeterRegistry())).configuration(StyxConfig.defaultConfig()).build();
plugins = List.of(namedPlugin("plug1", (request, chain) -> chain.proceed(request).map(response -> response.newBuilder().header("plug1", "1").build())), namedPlugin("plug2", (request, chain) -> chain.proceed(request).map(response -> response.newBuilder().header("plug2", "1").build())));
handler = mock(RoutingObject.class);
when(handler.handle(any(LiveHttpRequest.class), any(HttpInterceptor.Context.class))).thenReturn(Eventual.of(response(OK).build()));
}
use of com.hotels.styx.Environment in project styx by ExpediaGroup.
the class InstrumentedPluginTest method setUp.
@BeforeEach
public void setUp() {
registry = new MicrometerRegistry(new SimpleMeterRegistry());
environment = new Environment.Builder().registry(registry).build();
someRequest = get("/").build();
chain = mock(Chain.class);
}
use of com.hotels.styx.Environment in project styx by ExpediaGroup.
the class BackendServicesRouterTest method deregistersAndReregistersMetricsAppropriately.
// This test exists due to a real bug we had when reloading in prod
@Test
public void deregistersAndReregistersMetricsAppropriately() {
MeterRegistry metrics = new MicrometerRegistry(new SimpleMeterRegistry());
Environment environment = new Environment.Builder().registry(metrics).build();
MeterRegistry meterRegistry = environment.meterRegistry();
BackendServicesRouter router = new BackendServicesRouter(new StyxBackendServiceClientFactory(environment), environment, executor);
router.onChange(added(backendService(APP_B, "/appB/", 9094, "appB-01", 9095, "appB-02")));
Tags tags01 = Tags.of(APPID_TAG, APP_B, ORIGINID_TAG, "appB-01");
Tags tags02 = Tags.of(APPID_TAG, APP_B, ORIGINID_TAG, "appB-02");
assertThat(meterRegistry.find("proxy.client.originHealthStatus").tags(tags01).gauge().value(), is(1.0));
assertThat(meterRegistry.find("proxy.client.originHealthStatus").tags(tags02).gauge().value(), is(1.0));
BackendService appMinusOneOrigin = backendService(APP_B, "/appB/", 9094, "appB-01");
router.onChange(updated(appMinusOneOrigin));
assertThat(meterRegistry.find("proxy.client.originHealthStatus").tags(tags01).gauge().value(), is(1.0));
assertThat(meterRegistry.find("proxy.client.originHealthStatus").tags(tags02).gauge(), is(nullValue()));
}
Aggregations