org.springframework.cloud.client.loadbalancer.LoadBalancerClient Java Examples
The following examples show how to use
org.springframework.cloud.client.loadbalancer.LoadBalancerClient.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ApiBootLoggingAdminDiscoveryAutoConfiguration.java From api-boot with Apache License 2.0 | 6 votes |
/** * ApiBoot Logging Admin Registry Center Discovery * setting basic auth username if not empty {@link LoggingRegistryCenterAdminDiscovery#setUsername(String)} * setting basic auth password if not empty {@link LoggingRegistryCenterAdminDiscovery#setPassword(String)} * * @param loadBalancerClient LoadBalance Client * @return LoggingRegistryCenterAdminDiscovery */ @Bean @ConditionalOnMissingBean public LoggingAdminDiscovery loggingRegistryCenterAdminDiscovery(LoadBalancerClient loadBalancerClient) { LoggingRegistryCenterAdminDiscovery registryCenterAdminDiscovery = new LoggingRegistryCenterAdminDiscovery(apiBootLoggingProperties.getDiscovery().getServiceId(), loadBalancerClient); String basicAuthUserName = apiBootLoggingProperties.getDiscovery().getUsername(); if (!ObjectUtils.isEmpty(basicAuthUserName)) { registryCenterAdminDiscovery.setUsername(basicAuthUserName); } String basicAuthPassword = apiBootLoggingProperties.getDiscovery().getPassword(); if (!ObjectUtils.isEmpty(basicAuthPassword)) { registryCenterAdminDiscovery.setPassword(basicAuthPassword); } return registryCenterAdminDiscovery; }
Example #2
Source File: CamelCloudNetflixServiceLoadBalancerAutoConfigurationTest.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Test public void testAutoConfiguration() { new ApplicationContextRunner() .withConfiguration( AutoConfigurations.of( CamelAutoConfiguration.class, CamelCloudAutoConfiguration.class, CamelSpringCloudServiceRegistryAutoConfiguration.class, CamelCloudNetflixServiceLoadBalancerAutoConfiguration.class, RibbonAutoConfiguration.class, RibbonClientConfiguration.class )) .withUserConfiguration( TestConfiguration.class) .withPropertyValues( "debug=true", "spring.main.banner-mode=off", "ribbon.client.name=test") .run( context -> { assertThat(context).hasSingleBean(LoadBalancerClient.class); assertThat(context).getBean(LoadBalancerClient.class).isInstanceOf(RibbonLoadBalancerClient.class); assertThat(context).hasSingleBean(CamelSpringCloudServiceLoadBalancer.LoadBalancerClientAdapter.class); LoadBalancerClient client = context.getBean(LoadBalancerClient.class); ServiceLoadBalancer balancer = context.getBean(CamelSpringCloudServiceLoadBalancer.LoadBalancerClientAdapter.class).adapt(client); assertThat(balancer).isInstanceOf(CamelCloudNetflixServiceLoadBalancer.class); } ); }
Example #3
Source File: BlockingLoadBalancerClientAutoConfiguration.java From spring-cloud-commons with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnBean(LoadBalancerClientFactory.class) @ConditionalOnMissingBean public LoadBalancerClient blockingLoadBalancerClient( LoadBalancerClientFactory loadBalancerClientFactory) { return new BlockingLoadBalancerClient(loadBalancerClientFactory); }
Example #4
Source File: ServiceUtils.java From blog-microservices with Apache License 2.0 | 5 votes |
@Autowired public ServiceUtils( @Value("${server.port}") String port, LoadBalancerClient loadBalancer) { this.port = port; this.loadBalancer = loadBalancer; }
Example #5
Source File: CamelSpringCloudServiceLoadBalancerAutoConfiguration.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Bean(name = "load-balancer") @ConditionalOnMissingBean public ServiceLoadBalancer cloudLoadBalancer( LoadBalancerClient loadBalancerClient, Optional<CamelSpringCloudServiceLoadBalancer.LoadBalancerClientAdapter> clientAdapter) { return new CamelSpringCloudServiceLoadBalancer(loadBalancerClient, clientAdapter); }
Example #6
Source File: HttpClientFeignLoadBalancerConfiguration.java From spring-cloud-openfeign with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean public Client feignClient(LoadBalancerClient loadBalancerClient, HttpClient httpClient) { ApacheHttpClient delegate = new ApacheHttpClient(httpClient); return new FeignBlockingLoadBalancerClient(delegate, loadBalancerClient); }
Example #7
Source File: OkHttpFeignLoadBalancerConfiguration.java From spring-cloud-openfeign with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean public Client feignClient(okhttp3.OkHttpClient okHttpClient, LoadBalancerClient loadBalancerClient) { OkHttpClient delegate = new OkHttpClient(okHttpClient); return new FeignBlockingLoadBalancerClient(delegate, loadBalancerClient); }
Example #8
Source File: TracingFeignObjectWrapperTests.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@Test public void should_wrap_subclass_of_feign_loadbalancer_client() { Client delegate = mock(Client.class); BlockingLoadBalancerClient loadBalancerClient = mock( BlockingLoadBalancerClient.class); when(beanFactory.getBean(LoadBalancerClient.class)) .thenReturn(loadBalancerClient); Object wrapped = traceFeignObjectWrapper.wrap( new TestFeignBlockingLoadBalancerClient(delegate, loadBalancerClient)); assertThat(wrapped).isInstanceOf(TraceFeignBlockingLoadBalancerClient.class); }
Example #9
Source File: TracingFeignObjectWrapperTests.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@Test public void should_wrap_feign_loadbalancer_client() { Client delegate = mock(Client.class); BlockingLoadBalancerClient loadBalancerClient = mock( BlockingLoadBalancerClient.class); when(beanFactory.getBean(LoadBalancerClient.class)) .thenReturn(loadBalancerClient); Object wrapped = traceFeignObjectWrapper .wrap(new FeignBlockingLoadBalancerClient(delegate, loadBalancerClient)); assertThat(wrapped).isInstanceOf(TraceFeignBlockingLoadBalancerClient.class); }
Example #10
Source File: LoadBalancedResourceDetailsTest.java From jhipster with Apache License 2.0 | 5 votes |
@BeforeEach public void setup() { client = spy(LoadBalancerClient.class); doReturn(null).when(client).choose(TOKEN_SERVICE_ID); doAnswer(new Answer<URI>() { @Override public URI answer(InvocationOnMock invocation) throws Throwable { return invocation.getArgument(1); } }).when(client).reconstructURI(any(), any()); recorder = LogbackRecorder.forClass(LoadBalancedResourceDetails.class).reset().capture("ALL"); }
Example #11
Source File: MyfeedAutoConfig.java From myfeed with Apache License 2.0 | 4 votes |
@Bean public AsyncRestTemplate asyncRestTemplate(LoadBalancerInterceptor interceptor, LoadBalancerClient loadBalancer) { return asyncRest(interceptor, loadBalancer); }
Example #12
Source File: CommonsClientAutoConfiguration.java From spring-cloud-commons with Apache License 2.0 | 4 votes |
@Bean public HasFeatures commonsFeatures() { return HasFeatures.abstractFeatures(DiscoveryClient.class, LoadBalancerClient.class); }
Example #13
Source File: MyfeedAutoConfig.java From myfeed with Apache License 2.0 | 4 votes |
@Bean public TraversonFactory traversonFactory(LoadBalancerClient loadBalancerClient) { return new TraversonFactory(loadBalancerClient); }
Example #14
Source File: OkHttpRibbonInterceptor.java From spring-cloud-square with Apache License 2.0 | 4 votes |
public OkHttpRibbonInterceptor(LoadBalancerClient client) { this.client = client; }
Example #15
Source File: ManuallyCreatedLoadBalancerFeignClientTests.java From spring-cloud-sleuth with Apache License 2.0 | 4 votes |
@Bean public Client client(LoadBalancerClient blockingLoadBalancerClient) { return new MyBlockingClient(new MyDelegateClient(), blockingLoadBalancerClient); }
Example #16
Source File: ManuallyCreatedLoadBalancerFeignClientTests.java From spring-cloud-sleuth with Apache License 2.0 | 4 votes |
MyBlockingClient(Client delegate, LoadBalancerClient loadBalancerClient) { super(delegate, loadBalancerClient); }
Example #17
Source File: RetrofitRibbonNoAnnotationTests.java From spring-cloud-square with Apache License 2.0 | 4 votes |
@Bean public OkHttpRibbonInterceptor okHttpRibbonInterceptor(LoadBalancerClient loadBalancerClient) { return new OkHttpRibbonInterceptor(loadBalancerClient); }
Example #18
Source File: TraceFeignObjectWrapper.java From spring-cloud-sleuth with Apache License 2.0 | 4 votes |
private Object loadBalancerClient() { if (loadBalancerClient == null) { loadBalancerClient = beanFactory.getBean(LoadBalancerClient.class); } return loadBalancerClient; }
Example #19
Source File: OkHttpRibbonAutoConfiguration.java From spring-cloud-square with Apache License 2.0 | 4 votes |
@Bean public OkHttpRibbonInterceptor okHttpRibbonInterceptor(LoadBalancerClient client) { return new OkHttpRibbonInterceptor(client); }
Example #20
Source File: CustomRemoteTokenServices.java From microservice-integration with MIT License | 4 votes |
public void setLoadBalancerClient(LoadBalancerClient loadBalancerClient) { this.loadBalancerClient = loadBalancerClient; }
Example #21
Source File: MyfeedAutoConfig.java From myfeed with Apache License 2.0 | 4 votes |
@Bean public RibbonAsyncClientHttpRequestFactory asyncRequestFactory(LoadBalancerClient loadBalancerClient) { RibbonAsyncClientHttpRequestFactory requestFactory = new RibbonAsyncClientHttpRequestFactory(loadBalancerClient); requestFactory.setTaskExecutor(new SimpleAsyncTaskExecutor()); return requestFactory; }
Example #22
Source File: RibbonAsyncClientHttpRequestFactory.java From myfeed with Apache License 2.0 | 4 votes |
public RibbonAsyncClientHttpRequestFactory(LoadBalancerClient loadBalancer) { this.loadBalancer = loadBalancer; }
Example #23
Source File: TraversonFactory.java From myfeed with Apache License 2.0 | 4 votes |
public TraversonFactory(LoadBalancerClient loadBalancerClient) { this.loadBalancerClient = loadBalancerClient; }
Example #24
Source File: TLoadBalancerClient.java From spring-thrift-starter with MIT License | 4 votes |
public TLoadBalancerClient(LoadBalancerClient loadBalancerClient, String serviceName, String path) throws TTransportException { this.loadBalancerClient = loadBalancerClient; this.serviceName = serviceName; this.path = path; }
Example #25
Source File: AbstractMicroserviceClient.java From jhipster-ribbon-hystrix with GNU General Public License v3.0 | 4 votes |
@Autowired(required = false) public void setLoadBalancerClient(LoadBalancerClient loadBalancerClient) { this.loadBalancerClient = loadBalancerClient; }
Example #26
Source File: CustomerClient.java From microservice-consul with Apache License 2.0 | 4 votes |
@Autowired(required = false) public void setLoadBalancer(LoadBalancerClient loadBalancer) { this.loadBalancer = loadBalancer; }
Example #27
Source File: CatalogClient.java From microservice-consul with Apache License 2.0 | 4 votes |
@Autowired(required = false) public void setLoadBalancer(LoadBalancerClient loadBalancer) { this.loadBalancer = loadBalancer; }
Example #28
Source File: CatalogClient.java From microservice-consul with Apache License 2.0 | 4 votes |
@Autowired(required = false) public void setLoadBalancer(LoadBalancerClient loadBalancer) { this.loadBalancer = loadBalancer; }
Example #29
Source File: CustomerClient.java From microservice-consul with Apache License 2.0 | 4 votes |
@Autowired(required = false) public void setLoadBalancer(LoadBalancerClient loadBalancer) { this.loadBalancer = loadBalancer; }
Example #30
Source File: ZuulWebSocketConfiguration.java From spring-cloud-netflix-zuul-websocket with Apache License 2.0 | 4 votes |
@Bean public ProxyTargetResolver loadBalancedProxyTargetResolver( final ZuulProperties zuulProperties, final LoadBalancerClient loadBalancerClient) { return new LoadBalancedProxyTargetResolver(loadBalancerClient, zuulProperties); }