@Test public void should_retry() { Instance instance = Instance.create(InstanceId.of("id")) .register(Registration.create("test", wireMock.url("/mgmt/health")) .managementUrl(wireMock.url("/mgmt")) .build()); wireMock.stubFor(options(urlEqualTo("/mgmt/metrics")).inScenario("retry") .whenScenarioStateIs(STARTED) .willReturn(aResponse().withFixedDelay(5000)) .willSetStateTo("recovered")); wireMock.stubFor(options(urlEqualTo("/mgmt/metrics")).inScenario("retry") .whenScenarioStateIs("recovered") .willReturn(ok())); wireMock.stubFor(options(urlEqualTo("/mgmt/stats")).willReturn(ok())); wireMock.stubFor(options(urlEqualTo("/mgmt/info")).willReturn(ok())); wireMock.stubFor(options(urlEqualTo("/mgmt/non-exist")).willReturn(notFound())); ProbeEndpointsStrategy strategy = new ProbeEndpointsStrategy(instanceWebClient, new String[]{"metrics:stats", "metrics", "info", "non-exist"} ); StepVerifier.create(strategy.detectEndpoints(instance)) .expectNext(Endpoints.single("metrics", wireMock.url("/mgmt/stats")) .withEndpoint("info", wireMock.url("/mgmt/info"))) .verifyComplete(); }
@Override public Mono<Endpoints> detectEndpoints(Instance instance) { return Flux.fromIterable(endpoints) .flatMap(endpoint -> detectEndpoint(instance, endpoint)) .collectList() .flatMap(this::convert); }
ProbeEndpointsStrategy implements EndpointDetectionStrategy { @Override public Mono<Endpoints> detectEndpoints(Instance instance) { return Flux.fromIterable(endpoints) .flatMap(endpoint -> detectEndpoint(instance, endpoint)) .collectList() .flatMap(this::convert); } }
ProbeEndpointsStrategy implements EndpointDetectionStrategy { @Override public Mono<Endpoints> detectEndpoints(Instance instance) { return Flux.fromIterable(endpoints) .flatMap(endpoint -> detectEndpoint(instance, endpoint)) .collectList() .flatMap(this::convert); } ProbeEndpointsStrategy(InstanceWebClient instanceWebClient, String[] endpoints); }
ProbeEndpointsStrategy implements EndpointDetectionStrategy { @Override public Mono<Endpoints> detectEndpoints(Instance instance) { return Flux.fromIterable(endpoints) .flatMap(endpoint -> detectEndpoint(instance, endpoint)) .collectList() .flatMap(this::convert); } ProbeEndpointsStrategy(InstanceWebClient instanceWebClient, String[] endpoints); @Override Mono<Endpoints> detectEndpoints(Instance instance); }
ProbeEndpointsStrategy implements EndpointDetectionStrategy { @Override public Mono<Endpoints> detectEndpoints(Instance instance) { return Flux.fromIterable(endpoints) .flatMap(endpoint -> detectEndpoint(instance, endpoint)) .collectList() .flatMap(this::convert); } ProbeEndpointsStrategy(InstanceWebClient instanceWebClient, String[] endpoints); @Override Mono<Endpoints> detectEndpoints(Instance instance);  }