Class ConsulRegistryService
java.lang.Object
org.kiwiproject.registry.consul.server.ConsulRegistryService
- All Implemented Interfaces:
RegistryService
RegistryService
implementation for Consul discovery servers
NOTE: This class is intended to manage the registration and unregistration of a service with Consul. If your service is using a framework that has Consul integration, you might not want to use this class as it may attempt to register more than once (once from here and once from the framework integration)
-
Constructor Summary
ConstructorDescriptionConsulRegistryService
(org.kiwiproject.consul.Consul consul, ConsulRegistrationConfig config, org.kiwiproject.base.KiwiEnvironment environment) -
Method Summary
Modifier and TypeMethodDescriptioncreateCandidateFrom
(ServiceInfo serviceInfo) Creates a newServiceInstance
instance from aServiceInfo
that can be registered with the registry server.register
(ServiceInstance serviceToRegister) Registers aServiceInstance
with the registry server and returns a new instance containing information about the registered instance.void
Unregisters any registrations that were previously registered.updateStatus
(ServiceInstance.Status newStatus) Sends an update to the registry server to inform of a service status change
-
Constructor Details
-
ConsulRegistryService
public ConsulRegistryService(org.kiwiproject.consul.Consul consul, ConsulRegistrationConfig config, org.kiwiproject.base.KiwiEnvironment environment)
-
-
Method Details
-
createCandidateFrom
Description copied from interface:RegistryService
Creates a newServiceInstance
instance from aServiceInfo
that can be registered with the registry server.- Specified by:
createCandidateFrom
in interfaceRegistryService
- Parameters:
serviceInfo
- Service information that will be used to set up a new instance to be registered.- Returns:
- The
ServiceInstance
object that was created
-
register
Description copied from interface:RegistryService
Registers aServiceInstance
with the registry server and returns a new instance containing information about the registered instance.- Specified by:
register
in interfaceRegistryService
- Parameters:
serviceToRegister
- The service information to register- Returns:
- The service instance that was registered
-
updateStatus
Description copied from interface:RegistryService
Sends an update to the registry server to inform of a service status change- Specified by:
updateStatus
in interfaceRegistryService
- Parameters:
newStatus
- The new status that will be sent- Returns:
- a copy of the original
ServiceInstance
with the new status set
-
unregister
public void unregister()Description copied from interface:RegistryService
Unregisters any registrations that were previously registered. This should be a NO-OP if nothing has ever been registered.- Specified by:
unregister
in interfaceRegistryService
-