/** * Creates a new instance of {@link BulkheadExports} with default metrics names prefix and * {@link BulkheadRegistry} as a source of bulkheads. * @param bulkheadRegistry the registry of bulkheads */ public static BulkheadExports ofBulkheadRegistry(BulkheadRegistry bulkheadRegistry) { return new BulkheadExports(bulkheadRegistry.getAllBulkheads()); }
/** * Creates a new instance BulkheadMetrics {@link BulkheadMetrics} with specified metrics names prefix and * a {@link BulkheadRegistry} as a source. * * @param prefix the prefix of metrics names * @param bulkheadRegistry the registry of bulkheads */ public static BulkheadMetrics ofBulkheadRegistry(String prefix, BulkheadRegistry bulkheadRegistry) { return new BulkheadMetrics(prefix, bulkheadRegistry.getAllBulkheads()); }
/** * Creates a new instance BulkheadMetrics {@link BulkheadMetrics} with * a {@link BulkheadRegistry} as a source. * * @param bulkheadRegistry the registry of bulkheads */ public static BulkheadMetrics ofBulkheadRegistry(BulkheadRegistry bulkheadRegistry) { return new BulkheadMetrics(bulkheadRegistry.getAllBulkheads()); }
/** * Creates a new instance BulkheadMetrics {@link BulkheadMetrics} with * a {@link BulkheadRegistry} as a source. * * @param bulkheadRegistry the registry of bulkheads */ public static BulkheadMetrics ofBulkheadRegistry(BulkheadRegistry bulkheadRegistry) { return new BulkheadMetrics(bulkheadRegistry.getAllBulkheads()); }
metricRegistry.registerAll(BulkheadMetrics.ofIterable("testPre", bulkheadRegistry.getAllBulkheads()));
@Test public void shouldBeTheSameInstance() { Bulkhead bulkhead1 = registry.bulkhead("test", config); Bulkhead bulkhead2 = registry.bulkhead("test", config); assertThat(bulkhead1).isSameAs(bulkhead2); assertThat(registry.getAllBulkheads()).hasSize(1); }
@Test public void shouldBeNotTheSameInstance() { Bulkhead bulkhead1 = registry.bulkhead("test1"); Bulkhead bulkhead2 = registry.bulkhead("test2"); assertThat(bulkhead1).isNotSameAs(bulkhead2); assertThat(registry.getAllBulkheads()).hasSize(2); }
); chain1.get("stream/events", ctx -> { Seq<Flux<BulkheadEvent>> eventStreams = bulkheadRegistry.getAllBulkheads().map(bulkhead -> ReactorAdapter.toFlux(bulkhead.getEventPublisher())); Function<BulkheadEvent, String> data = b -> Jackson.getObjectWriter(chain1.getRegistry()).writeValueAsString(BulkheadEventDTO.createEventDTO(b)); ServerSentEvents events = ServerSentEvents.serverSentEvents(Flux.merge(eventStreams), e -> e.id(BulkheadEvent::getBulkheadName).event(c -> c.getEventType().name()).data(data)); chain1.get("stream/events/:name", ctx -> { String bulkheadName = ctx.getPathTokens().get("name"); Bulkhead bulkhead = bulkheadRegistry.getAllBulkheads().find(b -> b.getName().equals(bulkheadName)) .getOrElseThrow(() -> new IllegalArgumentException(String.format("bulkhead with name %s not found", bulkheadName))); Function<BulkheadEvent, String> data = b -> Jackson.getObjectWriter(chain1.getRegistry()).writeValueAsString(BulkheadEventDTO.createEventDTO(b)); String bulkheadName = ctx.getPathTokens().get("name"); String eventType = ctx.getPathTokens().get("type"); Bulkhead bulkhead = bulkheadRegistry.getAllBulkheads().find(b -> b.getName().equals(bulkheadName)) .getOrElseThrow(() -> new IllegalArgumentException(String.format("bulkhead with name %s not found", bulkheadName))); Flux<BulkheadEvent> eventStream = ReactorAdapter.toFlux(bulkhead.getEventPublisher())
/** * Creates a new instance BulkheadMetrics {@link BulkheadMetrics} with specified metrics names prefix and * a {@link BulkheadRegistry} as a source. * * @param prefix the prefix of metrics names * @param bulkheadRegistry the registry of bulkheads */ public static BulkheadMetrics ofBulkheadRegistry(String prefix, BulkheadRegistry bulkheadRegistry) { return new BulkheadMetrics(prefix, bulkheadRegistry.getAllBulkheads()); }
/** * Creates a new instance BulkheadMetrics {@link BulkheadMetrics} with * a {@link BulkheadRegistry} as a source. * * @param bulkheadRegistry the registry of bulkheads */ public static BulkheadMetrics ofBulkheadRegistry(BulkheadRegistry bulkheadRegistry) { return new BulkheadMetrics(bulkheadRegistry.getAllBulkheads()); }
); chain1.get("stream/events", ctx -> { Seq<Flux<BulkheadEvent>> eventStreams = bulkheadRegistry.getAllBulkheads().map(bulkhead -> ReactorAdapter.toFlux(bulkhead.getEventPublisher())); Function<BulkheadEvent, String> data = b -> Jackson.getObjectWriter(chain1.getRegistry()).writeValueAsString(BulkheadEventDTO.createEventDTO(b)); ServerSentEvents events = ServerSentEvents.serverSentEvents(Flux.merge(eventStreams), e -> e.id(BulkheadEvent::getBulkheadName).event(c -> c.getEventType().name()).data(data)); chain1.get("stream/events/:name", ctx -> { String bulkheadName = ctx.getPathTokens().get("name"); Bulkhead bulkhead = bulkheadRegistry.getAllBulkheads().find(b -> b.getName().equals(bulkheadName)) .getOrElseThrow(() -> new IllegalArgumentException(String.format("bulkhead with name %s not found", bulkheadName))); Function<BulkheadEvent, String> data = b -> Jackson.getObjectWriter(chain1.getRegistry()).writeValueAsString(BulkheadEventDTO.createEventDTO(b)); String bulkheadName = ctx.getPathTokens().get("name"); String eventType = ctx.getPathTokens().get("type"); Bulkhead bulkhead = bulkheadRegistry.getAllBulkheads().find(b -> b.getName().equals(bulkheadName)) .getOrElseThrow(() -> new IllegalArgumentException(String.format("bulkhead with name %s not found", bulkheadName))); Flux<BulkheadEvent> eventStream = ReactorAdapter.toFlux(bulkhead.getEventPublisher())