當前位置: 首頁>>代碼示例>>Java>>正文


Java DiscoveryClient類代碼示例

本文整理匯總了Java中org.springframework.cloud.client.discovery.DiscoveryClient的典型用法代碼示例。如果您正苦於以下問題:Java DiscoveryClient類的具體用法?Java DiscoveryClient怎麽用?Java DiscoveryClient使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DiscoveryClient類屬於org.springframework.cloud.client.discovery包,在下文中一共展示了DiscoveryClient類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: StoreProxyRouteLocator

import org.springframework.cloud.client.discovery.DiscoveryClient; //導入依賴的package包/類
/**
 * Creates new instance of {@link StoreProxyRouteLocator}
 * 
 * @param servletPath the application servlet path
 * @param discovery the discovery service
 * @param properties the zuul properties
 * @param store the route store
 */
public StoreProxyRouteLocator(String servletPath, DiscoveryClient discovery,
    ZuulProperties properties, ZuulRouteService store) {
  super(servletPath, discovery, properties);
  this.store = store;
  refreshExecutor.scheduleAtFixedRate(new Runnable() {

    @Override
    public void run() {
      try {
        refresh();
      } catch (Throwable e) {
        log.error(e.getMessage(), e);
      }
    }
  }, 0, 1, TimeUnit.MINUTES);
}
 
開發者ID:venus-boot,項目名稱:saluki,代碼行數:25,代碼來源:StoreProxyRouteLocator.java

示例2: customDiscoveryClient

import org.springframework.cloud.client.discovery.DiscoveryClient; //導入依賴的package包/類
@Bean
@Order(1)
public DiscoveryClient customDiscoveryClient() {
	return new DiscoveryClient() {
		@Override
		public String description() {
			return "A custom discovery client";
		}

		@Override
		public List<ServiceInstance> getInstances(String serviceId) {
			if (serviceId.equals("custom")) {
				ServiceInstance s1 = new DefaultServiceInstance("custom", "host",
						123, false);
				return Arrays.asList(s1);
			}
			return Collections.emptyList();
		}

		@Override
		public List<String> getServices() {
			return Arrays.asList("custom");
		}
	};
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-commons,代碼行數:26,代碼來源:CompositeDiscoveryClientTests.java

示例3: setUp

import org.springframework.cloud.client.discovery.DiscoveryClient; //導入依賴的package包/類
@Before
public void setUp() {
    discoveryClient = mock(DiscoveryClient.class);
    indexToNodeConverter = mock(IndexToNodeConverter.class);
    indexProperties = mock(IndexProperties.class);
    caller = mock(NettyServiceCaller.class);
    SecurityStrategyFactory securityStrategyFactory = mock(SecurityStrategyFactory.class);
    ApplicationEventPublisher publisher = mock(ApplicationEventPublisher.class);
    indexesAggregator = new IndexesAggregator(indexToNodeConverter, discoveryClient, new DefaultUriResolver(), indexProperties, publisher, caller, securityStrategyFactory);

    when(indexProperties.getFilteredServices()).thenReturn(
            Lists.newArrayList(HYSTRIX, DISK_SPACE, DISCOVERY, CONFIG_SERVER));
    when(indexProperties.getSecurity()).thenReturn(SecurityStrategyFactory.NONE);
    doReturn(new DefaultStrategyBeanProvider()).when(securityStrategyFactory).getStrategy(anyString());

}
 
開發者ID:ordina-jworks,項目名稱:microservices-dashboard-server,代碼行數:17,代碼來源:IndexesAggregatorTest.java

示例4: customDiscoveryClient1

import org.springframework.cloud.client.discovery.DiscoveryClient; //導入依賴的package包/類
@Bean
public DiscoveryClient customDiscoveryClient1() {
	return new DiscoveryClient() {
		@Override
		public String description() {
			return "A custom discovery client";
		}

		@Override
		public List<ServiceInstance> getInstances(String serviceId) {
			return null;
		}

		@Override
		public List<String> getServices() {
			return null;
		}
	};
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-commons,代碼行數:20,代碼來源:CompositeDiscoveryClientAutoConfigurationTests.java

示例5: zuulPropertiesResolver

import org.springframework.cloud.client.discovery.DiscoveryClient; //導入依賴的package包/類
@Bean
@ConditionalOnMissingBean
public ZuulPropertiesResolver zuulPropertiesResolver(
        final ZuulProperties zuulProperties, final DiscoveryClient discoveryClient) {
    Set<ZuulPropertiesResolver> resolvers = new HashSet<>();
    resolvers.add(new UrlPropertiesResolver(zuulProperties));
    resolvers.add(new EurekaPropertiesResolver(discoveryClient, zuulProperties));

    return new CompositeZuulPropertiesResolver(resolvers);
}
 
開發者ID:mthizo247,項目名稱:spring-cloud-netflix-zuul-websocket,代碼行數:11,代碼來源:ZuulWebSocketConfiguration.java

示例6: Cmd

import org.springframework.cloud.client.discovery.DiscoveryClient; //導入依賴的package包/類
@Autowired
public Cmd(ApplicationArguments args, @Qualifier("discoveryClientChannelFactory") GrpcChannelFactory channelFactory,
           DiscoveryClient discoveryClient) {
  discoveryClient.getServices();
  Channel channel = channelFactory.createChannel("EchoService");

  int i = 0;
  while (true) {
    EchoServiceGrpc.EchoServiceBlockingStub stub = EchoServiceGrpc.newBlockingStub(channel);
    EchoOuterClass.Echo response = stub.echo(EchoOuterClass.Echo.newBuilder().setMessage("Hello " + i).build());
    System.out.println("sent message #" + i);
    System.out.println("got response: " + response);
    i++;
  }
}
 
開發者ID:saturnism,項目名稱:grpc-java-by-example,代碼行數:16,代碼來源:Cmd.java

示例7: runner

import org.springframework.cloud.client.discovery.DiscoveryClient; //導入依賴的package包/類
@Bean
CommandLineRunner runner(DiscoveryClient dc) {
  return args -> {
    dc.getInstances("reservation-service")
            .forEach(si -> System.out.println(String.format(
                    "Found %s %s:%s", si.getServiceId(), si.getHost(), si.getPort())));
  };
}
 
開發者ID:nobodyiam,項目名稱:spring-cloud-in-action,代碼行數:9,代碼來源:ReservationClientApplication.java

示例8: CompositeInfoEndpoint

import org.springframework.cloud.client.discovery.DiscoveryClient; //導入依賴的package包/類
@SuppressWarnings("SpringJavaAutowiringInspection")
@Autowired
public CompositeInfoEndpoint(RestTemplate loadBalancedRestTemplate, DiscoveryClient discoveryClient, EurekaClient eurekaClient) {
	this.restTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactory(
			HttpClientBuilder.create().setSSLHostnameVerifier((s, sslSession) -> true).build()));

	this.loadBalancedRestTemplate = loadBalancedRestTemplate;
	this.discoveryClient = discoveryClient;
	this.eurekaClient = eurekaClient;
}
 
開發者ID:reportportal,項目名稱:service-gateway,代碼行數:11,代碼來源:CompositeInfoEndpoint.java

示例9: MappingsAggregator

import org.springframework.cloud.client.discovery.DiscoveryClient; //導入依賴的package包/類
@Deprecated
public MappingsAggregator(final DiscoveryClient discoveryClient, final UriResolver uriResolver,
						  final MappingsProperties properties, final NettyServiceCaller caller,
						  final ErrorHandler errorHandler) {
	this.discoveryClient = discoveryClient;
	this.uriResolver = uriResolver;
	this.properties = properties;
	this.caller = caller;
	this.errorHandler = errorHandler;
}
 
開發者ID:ordina-jworks,項目名稱:microservices-dashboard-server,代碼行數:11,代碼來源:MappingsAggregator.java

示例10: IndexesAggregator

import org.springframework.cloud.client.discovery.DiscoveryClient; //導入依賴的package包/類
@Deprecated
public IndexesAggregator(final IndexToNodeConverter indexToNodeConverter, final DiscoveryClient discoveryClient,
						 final UriResolver uriResolver, final IndexProperties properties,
						 final ApplicationEventPublisher publisher, final NettyServiceCaller caller) {
	this.indexToNodeConverter = indexToNodeConverter;
	this.discoveryClient = discoveryClient;
	this.uriResolver = uriResolver;
	this.properties = properties;
	this.publisher = publisher;
	this.caller = caller;
}
 
開發者ID:ordina-jworks,項目名稱:microservices-dashboard-server,代碼行數:12,代碼來源:IndexesAggregator.java

示例11: HealthIndicatorsAggregator

import org.springframework.cloud.client.discovery.DiscoveryClient; //導入依賴的package包/類
@Deprecated
public HealthIndicatorsAggregator(final DiscoveryClient discoveryClient, final UriResolver uriResolver,
								  final HealthProperties properties, final NettyServiceCaller caller,
								  final ErrorHandler errorHandler, final HealthToNodeConverter healthToNodeConverter) {
	this.discoveryClient = discoveryClient;
	this.uriResolver = uriResolver;
	this.properties = properties;
	this.caller = caller;
	this.errorHandler = errorHandler;
	this.healthToNodeConverter = healthToNodeConverter;
}
 
開發者ID:ordina-jworks,項目名稱:microservices-dashboard-server,代碼行數:12,代碼來源:HealthIndicatorsAggregator.java

示例12: testFixLink

import org.springframework.cloud.client.discovery.DiscoveryClient; //導入依賴的package包/類
@Test
public void testFixLink() throws Exception {
    ServiceRouteMapper mapper = new ModuleServiceMapper();
    DiscoveryClient discoveryClient = mock(DiscoveryClient.class);
    ResponseLinksMapper responseLinksMapper = new ResponseLinksMapper(mapper, discoveryClient);
    when(discoveryClient.getServices()).thenReturn(Collections.singletonList("service-module"));
    responseLinksMapper.fillServices();
    assertEquals("http://localhost:8080/api/service/entity", responseLinksMapper.fixLink("http://service-module/entity"));
}
 
開發者ID:thomasletsch,項目名稱:moserp,代碼行數:10,代碼來源:ResponseLinksMapperTest.java

示例13: StoreProxyRouteLocator

import org.springframework.cloud.client.discovery.DiscoveryClient; //導入依賴的package包/類
/**
 * Creates new instance of {@link StoreProxyRouteLocator}
 * @param servletPath the application servlet path
 * @param discovery the discovery service
 * @param properties the zuul properties
 * @param store the route store
 */
public StoreProxyRouteLocator(String servletPath,
                              DiscoveryClient discovery,
                              ZuulProperties properties,
                              ZuulRouteStore store) {
    super(servletPath, discovery, properties);
    this.store = store;
}
 
開發者ID:jmnarloch,項目名稱:zuul-route-cassandra-spring-cloud-starter,代碼行數:15,代碼來源:StoreProxyRouteLocator.java

示例14: should_find_an_instance_via_path_when_alias_is_not_found

import org.springframework.cloud.client.discovery.DiscoveryClient; //導入依賴的package包/類
@Test public void should_find_an_instance_via_path_when_alias_is_not_found() {
	// given:
	final DiscoveryClient discoveryClient = this.discoveryClient;
	// expect:
	await().until(new Callable<Boolean>() {
		@Override public Boolean call() throws Exception {
			return !discoveryClient.getInstances("nameWithoutAlias").isEmpty();
		}
	});
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-zookeeper,代碼行數:11,代碼來源:ZookeeperDiscoveryWithDependenciesIntegrationTests.java

示例15: should_find_a_collaborator_via_discovery_client

import org.springframework.cloud.client.discovery.DiscoveryClient; //導入依賴的package包/類
@Test public void should_find_a_collaborator_via_discovery_client() {
	// // given:
	final DiscoveryClient discoveryClient = this.discoveryClient;
	List<ServiceInstance> instances = discoveryClient.getInstances("someAlias");
	final ServiceInstance instance = instances.get(0);
	// expect:
	await().until(new Callable<Boolean>() {
		@Override public Boolean call() throws Exception {
			return callingServiceViaUrlOnBeansEndpointIsNotEmpty(instance);
		}
	});
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-zookeeper,代碼行數:13,代碼來源:ZookeeperDiscoveryWithDependenciesIntegrationTests.java


注:本文中的org.springframework.cloud.client.discovery.DiscoveryClient類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。