use of io.micronaut.discovery.event.ServiceReadyEvent in project micronaut-core by micronaut-projects.
the class NettyHttpServer method fireStartupEvents.
private void fireStartupEvents() {
Optional<String> applicationName = serverConfiguration.getApplicationConfiguration().getName();
applicationContext.getEventPublisher(ServerStartupEvent.class).publishEvent(new ServerStartupEvent(this));
applicationName.ifPresent(id -> {
this.serviceInstance = applicationContext.createBean(NettyEmbeddedServerInstance.class, id, this);
applicationContext.getEventPublisher(ServiceReadyEvent.class).publishEvent(new ServiceReadyEvent(serviceInstance));
});
}
use of io.micronaut.discovery.event.ServiceReadyEvent in project micronaut-core by micronaut-projects.
the class AutoRegistration method onApplicationEvent.
@Override
public void onApplicationEvent(AbstractServiceInstanceEvent event) {
if (registrationConfiguration.isEnabled()) {
if (event instanceof ServiceReadyEvent) {
register(event.getSource());
} else if (event instanceof ServiceStoppedEvent) {
if (registrationConfiguration.isDeregister()) {
deregister(event.getSource());
}
} else if (event instanceof HeartbeatEvent) {
HeartbeatEvent heartbeatEvent = (HeartbeatEvent) event;
pulsate(event.getSource(), heartbeatEvent.getStatus());
}
}
}
use of io.micronaut.discovery.event.ServiceReadyEvent in project micronaut-grpc by micronaut-projects.
the class GrpcEmbeddedServer method start.
@Override
public EmbeddedServer start() {
if (running.compareAndSet(false, true)) {
try {
server.start();
eventPublisher.publishEvent(new ServerStartupEvent(this));
getApplicationConfiguration().getName().ifPresent(id -> {
Map<String, String> metadata = new LinkedHashMap<>();
if (computeInstanceMetadataResolver != null) {
final Optional<ComputeInstanceMetadata> cim = computeInstanceMetadataResolver.resolve(applicationContext.getEnvironment());
cim.ifPresent(computeInstanceMetadata -> metadata.putAll(computeInstanceMetadata.getMetadata()));
}
this.serviceInstance = new GrpcServerInstance(this, id, getURI(), metadata, metadataContributors, grpcConfiguration);
applicationContext.publishEvent(new ServiceReadyEvent(serviceInstance));
});
} catch (IOException e) {
throw new ApplicationStartupException("Unable to start GRPC server: " + e.getMessage(), e);
}
}
return this;
}
Aggregations