Class GrpcNameResolverProvider

java.lang.Object
io.grpc.NameResolver.Factory
io.grpc.NameResolverProvider
io.micronaut.grpc.discovery.GrpcNameResolverProvider
All Implemented Interfaces:
io.micronaut.context.LifeCycle<GrpcNameResolverProvider>, Closeable, AutoCloseable

@Singleton @Requires(beans=io.micronaut.discovery.DiscoveryClient.class) @Requires(property="grpc.client.discovery.enabled",value="true",defaultValue="false") public class GrpcNameResolverProvider extends io.grpc.NameResolverProvider implements io.micronaut.context.LifeCycle<GrpcNameResolverProvider>
Implementation of NameResolverProvider that allows using Micronaut's DiscoveryClient to perform service discovery.
Since:
1.0
Author:
graemerocher
  • Field Details

  • Constructor Details

    • GrpcNameResolverProvider

      protected GrpcNameResolverProvider(io.micronaut.discovery.DiscoveryClient discoveryClient, List<io.micronaut.discovery.ServiceInstanceList> serviceInstanceLists)
      Default constructor.
      Parameters:
      discoveryClient - The discovery client
      serviceInstanceLists - The server instance list
  • Method Details

    • isAvailable

      protected boolean isAvailable()
      Specified by:
      isAvailable in class io.grpc.NameResolverProvider
    • priority

      protected int priority()
      Specified by:
      priority in class io.grpc.NameResolverProvider
    • newNameResolver

      public io.grpc.NameResolver newNameResolver(URI targetUri, io.grpc.NameResolver.Args args)
      Specified by:
      newNameResolver in class io.grpc.NameResolver.Factory
    • getDefaultScheme

      public String getDefaultScheme()
      Specified by:
      getDefaultScheme in class io.grpc.NameResolver.Factory
    • isRunning

      public boolean isRunning()
      Specified by:
      isRunning in interface io.micronaut.context.LifeCycle<GrpcNameResolverProvider>
    • start

      @NonNull @PostConstruct public @NonNull GrpcNameResolverProvider start()
      Specified by:
      start in interface io.micronaut.context.LifeCycle<GrpcNameResolverProvider>
    • stop

      @NonNull @PreDestroy public @NonNull GrpcNameResolverProvider stop()
      Specified by:
      stop in interface io.micronaut.context.LifeCycle<GrpcNameResolverProvider>