Java Code Examples for org.springframework.cloud.client.discovery.DiscoveryClient#getServices()

The following examples show how to use org.springframework.cloud.client.discovery.DiscoveryClient#getServices() . 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: Cmd.java    From grpc-by-example-java with Apache License 2.0 6 votes vote down vote up
@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++;
  }
}
 
Example 2
Source File: DiscoveryClientHealthIndicator.java    From spring-cloud-commons with Apache License 2.0 6 votes vote down vote up
@Override
public Health health() {
	Health.Builder builder = new Health.Builder();

	if (this.discoveryInitialized.get()) {
		try {
			DiscoveryClient client = this.discoveryClient.getIfAvailable();
			List<String> services = client.getServices();
			String description = (this.properties.isIncludeDescription())
					? client.description() : "";
			builder.status(new Status("UP", description)).withDetail("services",
					services);
		}
		catch (Exception e) {
			this.log.error("Error", e);
			builder.down(e);
		}
	}
	else {
		builder.status(new Status(Status.UNKNOWN.getCode(),
				"Discovery Client not initialized"));
	}
	return builder.build();
}
 
Example 3
Source File: UaaSignatureVerifierClient.java    From cubeai with Apache License 2.0 5 votes vote down vote up
public UaaSignatureVerifierClient(DiscoveryClient discoveryClient, @Qualifier("loadBalancedRestTemplate") RestTemplate restTemplate,
                              OAuth2Properties oAuth2Properties) {
    this.restTemplate = restTemplate;
    this.oAuth2Properties = oAuth2Properties;
    // Load available UAA servers
    discoveryClient.getServices();
}
 
Example 4
Source File: UaaSignatureVerifierClient.java    From cubeai with Apache License 2.0 5 votes vote down vote up
public UaaSignatureVerifierClient(DiscoveryClient discoveryClient, @Qualifier("loadBalancedRestTemplate") RestTemplate restTemplate,
                              OAuth2Properties oAuth2Properties) {
    this.restTemplate = restTemplate;
    this.oAuth2Properties = oAuth2Properties;
    // Load available UAA servers
    discoveryClient.getServices();
}
 
Example 5
Source File: UaaSignatureVerifierClient.java    From cubeai with Apache License 2.0 5 votes vote down vote up
public UaaSignatureVerifierClient(DiscoveryClient discoveryClient, @Qualifier("loadBalancedRestTemplate") RestTemplate restTemplate,
                              OAuth2Properties oAuth2Properties) {
    this.restTemplate = restTemplate;
    this.oAuth2Properties = oAuth2Properties;
    // Load available UAA servers
    discoveryClient.getServices();
}
 
Example 6
Source File: UaaSignatureVerifierClient.java    From cubeai with Apache License 2.0 5 votes vote down vote up
public UaaSignatureVerifierClient(DiscoveryClient discoveryClient, @Qualifier("loadBalancedRestTemplate") RestTemplate restTemplate,
                              OAuth2Properties oAuth2Properties) {
    this.restTemplate = restTemplate;
    this.oAuth2Properties = oAuth2Properties;
    // Load available UAA servers
    discoveryClient.getServices();
}
 
Example 7
Source File: UaaSignatureVerifierClient.java    From cubeai with Apache License 2.0 5 votes vote down vote up
public UaaSignatureVerifierClient(DiscoveryClient discoveryClient, @Qualifier("loadBalancedRestTemplate") RestTemplate restTemplate,
                              OAuth2Properties oAuth2Properties) {
    this.restTemplate = restTemplate;
    this.oAuth2Properties = oAuth2Properties;
    // Load available UAA servers
    discoveryClient.getServices();
}
 
Example 8
Source File: UaaSignatureVerifierClient.java    From cubeai with Apache License 2.0 5 votes vote down vote up
public UaaSignatureVerifierClient(DiscoveryClient discoveryClient, @Qualifier("loadBalancedRestTemplate") RestTemplate restTemplate,
                              OAuth2Properties oAuth2Properties) {
    this.restTemplate = restTemplate;
    this.oAuth2Properties = oAuth2Properties;
    // Load available UAA servers
    discoveryClient.getServices();
}
 
Example 9
Source File: UaaSignatureVerifierClient.java    From cubeai with Apache License 2.0 5 votes vote down vote up
public UaaSignatureVerifierClient(DiscoveryClient discoveryClient, @Qualifier("loadBalancedRestTemplate") RestTemplate restTemplate,
                              OAuth2Properties oAuth2Properties) {
    this.restTemplate = restTemplate;
    this.oAuth2Properties = oAuth2Properties;
    // Load available UAA servers
    discoveryClient.getServices();
}
 
Example 10
Source File: CompositeDiscoveryClient.java    From spring-cloud-commons with Apache License 2.0 5 votes vote down vote up
@Override
public List<String> getServices() {
	LinkedHashSet<String> services = new LinkedHashSet<>();
	if (this.discoveryClients != null) {
		for (DiscoveryClient discoveryClient : this.discoveryClients) {
			List<String> serviceForClient = discoveryClient.getServices();
			if (serviceForClient != null) {
				services.addAll(serviceForClient);
			}
		}
	}
	return new ArrayList<>(services);
}
 
Example 11
Source File: UaaSignatureVerifierClient.java    From tutorials with MIT License 5 votes vote down vote up
public UaaSignatureVerifierClient(DiscoveryClient discoveryClient, @Qualifier("loadBalancedRestTemplate") RestTemplate restTemplate,
                              OAuth2Properties oAuth2Properties) {
    this.restTemplate = restTemplate;
    this.oAuth2Properties = oAuth2Properties;
    // Load available UAA servers
    discoveryClient.getServices();
}
 
Example 12
Source File: UaaSignatureVerifierClient.java    From tutorials with MIT License 5 votes vote down vote up
public UaaSignatureVerifierClient(DiscoveryClient discoveryClient, @Qualifier("loadBalancedRestTemplate") RestTemplate restTemplate,
                              OAuth2Properties oAuth2Properties) {
    this.restTemplate = restTemplate;
    this.oAuth2Properties = oAuth2Properties;
    // Load available UAA servers
    discoveryClient.getServices();
}