@Singleton @Requires(classes=com.amazonaws.services.servicediscovery.AWSServiceDiscovery.class) @Requires(env="ec2") @Requires(beans=Route53AutoRegistrationConfiguration.class) @Requires(property="aws.route53.registration.enabled",value="true",defaultValue="false") @Requires(property="micronaut.application.name") public class Route53AutoNamingRegistrationClient extends io.micronaut.discovery.client.registration.DiscoveryServiceAutoRegistration
DiscoveryServiceAutoRegistration
for Route 53.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
AWS_ALIAS_DNS_NAME
Constant for AWS alias dns name.
|
static java.lang.String |
AWS_INSTANCE_CNAME
Constant for AWS instance cname.
|
static java.lang.String |
AWS_INSTANCE_IPV4
Constant for AWS intance IPv4.
|
static java.lang.String |
AWS_INSTANCE_IPV6
Constant for AWS instance IPv6.
|
static java.lang.String |
AWS_INSTANCE_PORT
Constant for AWS instance port.
|
static java.lang.String |
ENABLED
Constant for whether route 53 registration is enabled.
|
Modifier | Constructor and Description |
---|---|
protected |
Route53AutoNamingRegistrationClient(io.micronaut.context.env.Environment environment,
Route53AutoRegistrationConfiguration route53AutoRegistrationConfiguration,
AWSClientConfiguration clientConfiguration,
io.micronaut.discovery.cloud.aws.AmazonComputeInstanceMetadataResolver amazonComputeInstanceMetadataResolver,
java.util.concurrent.Executor executorService,
AWSServiceDiscoveryResolver awsServiceDiscoveryResolver)
Constructor for setup.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
createNamespace(java.lang.String name)
This is a helper method for integration tests to create a new namespace.
|
java.lang.String |
createService(com.amazonaws.services.servicediscovery.AWSServiceDiscovery serviceDiscovery,
java.lang.String name,
java.lang.String description,
java.lang.String namespaceId,
java.lang.Long ttl)
Create service, helper for integration tests.
|
void |
deleteNamespace(java.lang.String namespaceId)
these are convenience methods to help cleanup things like integration test data.
|
void |
deleteService(java.lang.String serviceId)
These are convenience methods to help cleanup things like integration test data.
|
protected void |
deregister(io.micronaut.discovery.ServiceInstance instance)
shutdown instance if it fails health check can gracefully stop.
|
com.amazonaws.services.servicediscovery.AWSServiceDiscoveryAsync |
getDiscoveryClient()
Gets the discovery client Impl for easier testing.
|
com.amazonaws.services.servicediscovery.model.Service |
getDiscoveryService()
Gets the discovery service used on route53.
|
protected void |
pulsate(io.micronaut.discovery.ServiceInstance instance,
io.micronaut.health.HealthStatus status)
If custom health check is enabled, this sends a heartbeat to it.
|
protected void |
register(io.micronaut.discovery.ServiceInstance instance)
register new instance to the service registry.
|
void |
setDiscoveryService(com.amazonaws.services.servicediscovery.model.Service discoveryService)
Used for testing.
|
getErrorMessage, performDeregistration, performRegistration
onApplicationEvent, validateApplicationName, validateName
public static final java.lang.String AWS_INSTANCE_PORT
public static final java.lang.String AWS_INSTANCE_IPV4
public static final java.lang.String AWS_INSTANCE_CNAME
public static final java.lang.String AWS_INSTANCE_IPV6
public static final java.lang.String AWS_ALIAS_DNS_NAME
public static final java.lang.String ENABLED
protected Route53AutoNamingRegistrationClient(io.micronaut.context.env.Environment environment, Route53AutoRegistrationConfiguration route53AutoRegistrationConfiguration, AWSClientConfiguration clientConfiguration, io.micronaut.discovery.cloud.aws.AmazonComputeInstanceMetadataResolver amazonComputeInstanceMetadataResolver, @Named(value="io") java.util.concurrent.Executor executorService, AWSServiceDiscoveryResolver awsServiceDiscoveryResolver)
environment
- current environemntsroute53AutoRegistrationConfiguration
- config for auto registrationclientConfiguration
- general client configuraitonamazonComputeInstanceMetadataResolver
- resolver for aws compute metdataexecutorService
- this is for executing the thread to monitor the register operation for completionawsServiceDiscoveryResolver
- this allows is to swap out the bean for a mock version for unit testingprotected void pulsate(io.micronaut.discovery.ServiceInstance instance, io.micronaut.health.HealthStatus status)
pulsate
in class io.micronaut.discovery.registration.AutoRegistration
instance
- The instance of the servicestatus
- The HealthStatus
protected void deregister(io.micronaut.discovery.ServiceInstance instance)
deregister
in class io.micronaut.discovery.registration.AutoRegistration
protected void register(io.micronaut.discovery.ServiceInstance instance)
register
in class io.micronaut.discovery.registration.AutoRegistration
instance
- The ServiceInstance
public void deleteService(java.lang.String serviceId)
serviceId
- service id from AWS to deletepublic void deleteNamespace(java.lang.String namespaceId)
namespaceId
- namespace ID from AWS to deletepublic java.lang.String createNamespace(java.lang.String name)
name
- name of the namespace in your route53public java.lang.String createService(com.amazonaws.services.servicediscovery.AWSServiceDiscovery serviceDiscovery, java.lang.String name, java.lang.String description, java.lang.String namespaceId, java.lang.Long ttl)
serviceDiscovery
- service discovery instancename
- name of the servicedescription
- description of the servicenamespaceId
- namespaceId to attach it to (get via cli or api call)ttl
- time to live for checking pulsepublic com.amazonaws.services.servicediscovery.AWSServiceDiscoveryAsync getDiscoveryClient()
public com.amazonaws.services.servicediscovery.model.Service getDiscoveryService()
public void setDiscoveryService(com.amazonaws.services.servicediscovery.model.Service discoveryService)
discoveryService
- service reference on route53 on AWS