From 40993732b302ce43ae1dbedbda44cc0113e9b6f2 Mon Sep 17 00:00:00 2001 From: Piotr Jaszczyk Date: Wed, 23 Jan 2019 09:51:50 +0100 Subject: Change Health Status when shutting down Change-Id: I889c934f29d34c1211c6e07f18cb16bbe35d711f Issue-ID: DCAEGEN2-1065 Signed-off-by: Piotr Jaszczyk --- .../main/kotlin/org/onap/dcae/collectors/veshv/main/main.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'sources/hv-collector-main/src/main') diff --git a/sources/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/main.kt b/sources/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/main.kt index d865bcf5..df2316b7 100644 --- a/sources/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/main.kt +++ b/sources/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/main.kt @@ -22,7 +22,10 @@ package org.onap.dcae.collectors.veshv.main import arrow.effects.IO import arrow.effects.fix import arrow.effects.instances.io.monad.monad +import arrow.effects.instances.io.monadError.monadError import arrow.typeclasses.binding +import org.onap.dcae.collectors.veshv.healthcheck.api.HealthDescription +import org.onap.dcae.collectors.veshv.healthcheck.api.HealthState import org.onap.dcae.collectors.veshv.main.servers.HealthCheckServer import org.onap.dcae.collectors.veshv.main.servers.VesServer import org.onap.dcae.collectors.veshv.model.ServerConfiguration @@ -63,7 +66,9 @@ private fun startAndAwaitServers(config: ServerConfiguration) = } }.fix() -private fun closeServers(vararg handles: ServerHandle): IO = - Closeable.closeAll(handles.asIterable()).then { +internal fun closeServers(vararg handles: ServerHandle, healthState: HealthState = HealthState.INSTANCE): IO = + IO.monadError().binding { + healthState.changeState(HealthDescription.SHUTTING_DOWN) + Closeable.closeAll(handles.asIterable()).bind() logger.info(ServiceContext::mdc) { "Graceful shutdown completed" } - } + }.fix() -- cgit 1.2.3-korg