Package io.micronaut.grpc.discovery
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 Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
GrpcNameResolverProvider
(io.micronaut.discovery.DiscoveryClient discoveryClient, List<io.micronaut.discovery.ServiceInstanceList> serviceInstanceLists) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
boolean
io.grpc.NameResolver
newNameResolver
(URI targetUri, io.grpc.NameResolver.Args args) protected int
priority()
@NonNull GrpcNameResolverProvider
start()
@NonNull GrpcNameResolverProvider
stop()
Methods inherited from class io.grpc.NameResolverProvider
getProducedSocketAddressTypes, getScheme
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.context.LifeCycle
close, refresh
-
Field Details
-
ENABLED
- See Also:
-
PRIORITY
public static final int PRIORITY- See Also:
-
-
Constructor Details
-
GrpcNameResolverProvider
protected GrpcNameResolverProvider(io.micronaut.discovery.DiscoveryClient discoveryClient, List<io.micronaut.discovery.ServiceInstanceList> serviceInstanceLists) Default constructor.- Parameters:
discoveryClient
- The discovery clientserviceInstanceLists
- The server instance list
-
-
Method Details
-
isAvailable
protected boolean isAvailable()- Specified by:
isAvailable
in classio.grpc.NameResolverProvider
-
priority
protected int priority()- Specified by:
priority
in classio.grpc.NameResolverProvider
-
newNameResolver
- Specified by:
newNameResolver
in classio.grpc.NameResolver.Factory
-
getDefaultScheme
- Specified by:
getDefaultScheme
in classio.grpc.NameResolver.Factory
-
isRunning
public boolean isRunning()- Specified by:
isRunning
in interfaceio.micronaut.context.LifeCycle<GrpcNameResolverProvider>
-
start
- Specified by:
start
in interfaceio.micronaut.context.LifeCycle<GrpcNameResolverProvider>
-
stop
- Specified by:
stop
in interfaceio.micronaut.context.LifeCycle<GrpcNameResolverProvider>
-