@Test void newClientBuilderCustomizationOrder() { final ClientFactory cf1 = mock(ClientFactory.class); final ClientFactory cf2 = mock(ClientFactory.class); final ClientFactory cf3 = mock(ClientFactory.class); final ArmeriaCentralDogmaBuilder b = new ArmeriaCentralDogmaBuilder(); final StringBuilder buf = new StringBuilder(); b.clientFactory(cf1); b.clientConfigurator(cb -> { buf.append('2'); cb.factory(cf2); }); final ClientBuilder cb = b.newClientBuilder("none+http", Endpoint.of("127.0.0.1"), cb2 -> { cb2.factory(cf3); buf.append('1'); }, "/"); assertThat(buf.toString()).isEqualTo("12"); cb.build(HttpClient.class); verify(cf1, times(1)).newClient(any()); verify(cf2, never()).newClient(any()); verify(cf3, never()).newClient(any()); }
public CentralDogma build() throws UnknownHostException { final EndpointGroup endpointGroup = endpointGroup(); final String scheme = "none+" + (isUseTls() ? "https" : "http"); final ClientBuilder builder = newClientBuilder(scheme, endpointGroup, cb -> cb.decorator(DecodingClient.newDecorator()), "/"); final EventLoopGroup executor = clientFactory().eventLoopGroup(); final int maxRetriesOnReplicationLag = maxNumRetriesOnReplicationLag(); final CentralDogma dogma = new ArmeriaCentralDogma(executor, builder.build(WebClient.class), accessToken()); if (maxRetriesOnReplicationLag <= 0) { return dogma; } else { return new ReplicationLagTolerantCentralDogma( executor, dogma, maxRetriesOnReplicationLag, retryIntervalOnReplicationLagMillis(), () -> { final ClientRequestContext ctx = ClientRequestContext.currentOrNull(); return ctx != null ? ctx.remoteAddress() : null; }); } }
ArmeriaCentralDogmaBuilder extends AbstractArmeriaCentralDogmaBuilder<ArmeriaCentralDogmaBuilder> { public CentralDogma build() throws UnknownHostException { final EndpointGroup endpointGroup = endpointGroup(); final String scheme = "none+" + (isUseTls() ? "https" : "http"); final ClientBuilder builder = newClientBuilder(scheme, endpointGroup, cb -> cb.decorator(DecodingClient.newDecorator()), "/"); final EventLoopGroup executor = clientFactory().eventLoopGroup(); final int maxRetriesOnReplicationLag = maxNumRetriesOnReplicationLag(); final CentralDogma dogma = new ArmeriaCentralDogma(executor, builder.build(WebClient.class), accessToken()); if (maxRetriesOnReplicationLag <= 0) { return dogma; } else { return new ReplicationLagTolerantCentralDogma( executor, dogma, maxRetriesOnReplicationLag, retryIntervalOnReplicationLagMillis(), () -> { final ClientRequestContext ctx = ClientRequestContext.currentOrNull(); return ctx != null ? ctx.remoteAddress() : null; }); } } }
ArmeriaCentralDogmaBuilder extends AbstractArmeriaCentralDogmaBuilder<ArmeriaCentralDogmaBuilder> { public CentralDogma build() throws UnknownHostException { final EndpointGroup endpointGroup = endpointGroup(); final String scheme = "none+" + (isUseTls() ? "https" : "http"); final ClientBuilder builder = newClientBuilder(scheme, endpointGroup, cb -> cb.decorator(DecodingClient.newDecorator()), "/"); final EventLoopGroup executor = clientFactory().eventLoopGroup(); final int maxRetriesOnReplicationLag = maxNumRetriesOnReplicationLag(); final CentralDogma dogma = new ArmeriaCentralDogma(executor, builder.build(WebClient.class), accessToken()); if (maxRetriesOnReplicationLag <= 0) { return dogma; } else { return new ReplicationLagTolerantCentralDogma( executor, dogma, maxRetriesOnReplicationLag, retryIntervalOnReplicationLagMillis(), () -> { final ClientRequestContext ctx = ClientRequestContext.currentOrNull(); return ctx != null ? ctx.remoteAddress() : null; }); } }  }
ArmeriaCentralDogmaBuilder extends AbstractArmeriaCentralDogmaBuilder<ArmeriaCentralDogmaBuilder> { public CentralDogma build() throws UnknownHostException { final EndpointGroup endpointGroup = endpointGroup(); final String scheme = "none+" + (isUseTls() ? "https" : "http"); final ClientBuilder builder = newClientBuilder(scheme, endpointGroup, cb -> cb.decorator(DecodingClient.newDecorator()), "/"); final EventLoopGroup executor = clientFactory().eventLoopGroup(); final int maxRetriesOnReplicationLag = maxNumRetriesOnReplicationLag(); final CentralDogma dogma = new ArmeriaCentralDogma(executor, builder.build(WebClient.class), accessToken()); if (maxRetriesOnReplicationLag <= 0) { return dogma; } else { return new ReplicationLagTolerantCentralDogma( executor, dogma, maxRetriesOnReplicationLag, retryIntervalOnReplicationLagMillis(), () -> { final ClientRequestContext ctx = ClientRequestContext.currentOrNull(); return ctx != null ? ctx.remoteAddress() : null; }); } }  CentralDogma build(); }
ArmeriaCentralDogmaBuilder extends AbstractArmeriaCentralDogmaBuilder<ArmeriaCentralDogmaBuilder> { public CentralDogma build() throws UnknownHostException { final EndpointGroup endpointGroup = endpointGroup(); final String scheme = "none+" + (isUseTls() ? "https" : "http"); final ClientBuilder builder = newClientBuilder(scheme, endpointGroup, cb -> cb.decorator(DecodingClient.newDecorator()), "/"); final EventLoopGroup executor = clientFactory().eventLoopGroup(); final int maxRetriesOnReplicationLag = maxNumRetriesOnReplicationLag(); final CentralDogma dogma = new ArmeriaCentralDogma(executor, builder.build(WebClient.class), accessToken()); if (maxRetriesOnReplicationLag <= 0) { return dogma; } else { return new ReplicationLagTolerantCentralDogma( executor, dogma, maxRetriesOnReplicationLag, retryIntervalOnReplicationLagMillis(), () -> { final ClientRequestContext ctx = ClientRequestContext.currentOrNull(); return ctx != null ? ctx.remoteAddress() : null; }); } }  CentralDogma build();  }