spring-cloud-commons icon indicating copy to clipboard operation
spring-cloud-commons copied to clipboard

Add API to register services generically

Open ST-DDT opened this issue 4 years ago • 0 comments

Is your feature request related to a problem? Please describe.

I maintain a library that provides services via grpc. (https://github.com/yidongnan/grpc-spring-boot-starter) I would like to provide my users with support for their spring-cloud service discovery implementation without me having to implement all of them myself.

Describe the solution you'd like

An API that allows me to register a service generically.

serviceRegistry.newRegistrationBuilder()
    .id("my-service-grpc") // Setters for all common attributes
    .host("10.0.13.37")
    .port(15)
    .name("x")
    .secure("y") 
   [...]
    .properties(someProperties) // Can be used to set implementation specific values (if there are any)
    .metadata(someMetadata)
    .register(); // Fires the events and registers the service

To improve compatibility the method could also return an Optional<RegistrationBuilder> and return Optional.empty() by default. If you approve the concept of this API, then I'm willing (to try) to implement it for commons, eureka, consul, and nacos.

Describe alternatives you've considered

  • Either manually implement them myself
  • or attach additional metadata to the spring-web registrations and repurpose them <-- current workaround (with a slight reduction of compatibility)

Additional context

  • https://github.com/yidongnan/grpc-spring-boot-starter/issues/622

ST-DDT avatar Jan 11 '22 10:01 ST-DDT