Class ConsulRegistryService
- java.lang.Object
-
- org.kiwiproject.registry.consul.server.ConsulRegistryService
-
- All Implemented Interfaces:
RegistryService
public class ConsulRegistryService extends Object implements RegistryService
RegistryServiceimplementation for Consul discovery serversNOTE: 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
Constructors Constructor Description ConsulRegistryService(com.orbitz.consul.Consul consul, ConsulRegistrationConfig config, org.kiwiproject.base.KiwiEnvironment environment)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ServiceInstancecreateCandidateFrom(ServiceInfo serviceInfo)Creates a newServiceInstanceinstance from aServiceInfothat can be registered with the registry server.ServiceInstanceregister(ServiceInstance serviceToRegister)Registers aServiceInstancewith the registry server and returns a new instance containing information about the registered instance.voidunregister()Unregisters any registrations that were previously registered.ServiceInstanceupdateStatus(ServiceInstance.Status newStatus)Sends an update to the registry server to inform of a service status change
-
-
-
Constructor Detail
-
ConsulRegistryService
public ConsulRegistryService(com.orbitz.consul.Consul consul, ConsulRegistrationConfig config, org.kiwiproject.base.KiwiEnvironment environment)
-
-
Method Detail
-
createCandidateFrom
public ServiceInstance createCandidateFrom(ServiceInfo serviceInfo)
Description copied from interface:RegistryServiceCreates a newServiceInstanceinstance from aServiceInfothat can be registered with the registry server.- Specified by:
createCandidateFromin interfaceRegistryService- Parameters:
serviceInfo- Service information that will be used to setup a new instance to be registered.- Returns:
- The
ServiceInstanceobject that was created
-
register
public ServiceInstance register(ServiceInstance serviceToRegister)
Description copied from interface:RegistryServiceRegisters aServiceInstancewith the registry server and returns a new instance containing information about the registered instance.- Specified by:
registerin interfaceRegistryService- Parameters:
serviceToRegister- The service information to register- Returns:
- The service instance that was registered
-
updateStatus
public ServiceInstance updateStatus(ServiceInstance.Status newStatus)
Description copied from interface:RegistryServiceSends an update to the registry server to inform of a service status change- Specified by:
updateStatusin interfaceRegistryService- Parameters:
newStatus- The new status that will be sent- Returns:
- a copy of the original
ServiceInstancewith the new status set
-
unregister
public void unregister()
Description copied from interface:RegistryServiceUnregisters any registrations that were previously registered. This should be a NO-OP if nothing has ever been registered.- Specified by:
unregisterin interfaceRegistryService
-
-