From dd827e2c1cc984d9ed1fed9914cbef0e985ea625 Mon Sep 17 00:00:00 2001 From: Jakub Dudycz Date: Tue, 7 Aug 2018 14:18:37 +0200 Subject: Create health check module Create ves-hv-collector-health-check module with dummy api server and connect it with ves-hv-collector-main This is a preparation for health check mechanism implementation Change-Id: I2f668ab7337b1ed7e2afea6c56f34880de3ef1b5 Issue-ID: DCAEGEN2-659 Signed-off-by: Jakub Dudycz --- hv-collector-health-check/pom.xml | 57 ++++++++++++++++++++++ .../veshv/healthcheck/http/HealthCheckApiServer.kt | 49 +++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 hv-collector-health-check/pom.xml create mode 100644 hv-collector-health-check/src/main/kotlin/org/onap/dcae/collectors/veshv/healthcheck/http/HealthCheckApiServer.kt (limited to 'hv-collector-health-check') diff --git a/hv-collector-health-check/pom.xml b/hv-collector-health-check/pom.xml new file mode 100644 index 00000000..4072ec24 --- /dev/null +++ b/hv-collector-health-check/pom.xml @@ -0,0 +1,57 @@ + + + + 4.0.0 + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + + + + + false + false + + + + org.onap.dcaegen2.collectors.veshv + ves-hv-collector + 1.0.0-SNAPSHOT + .. + + + hv-collector-health-check + VES HighVolume Collector :: Health check + + + + + kotlin-maven-plugin + org.jetbrains.kotlin + + + maven-surefire-plugin + org.apache.maven.plugins + + + + + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + + + io.ratpack + ratpack-core + + + io.arrow-kt + arrow-effects + + + \ No newline at end of file diff --git a/hv-collector-health-check/src/main/kotlin/org/onap/dcae/collectors/veshv/healthcheck/http/HealthCheckApiServer.kt b/hv-collector-health-check/src/main/kotlin/org/onap/dcae/collectors/veshv/healthcheck/http/HealthCheckApiServer.kt new file mode 100644 index 00000000..9cab031a --- /dev/null +++ b/hv-collector-health-check/src/main/kotlin/org/onap/dcae/collectors/veshv/healthcheck/http/HealthCheckApiServer.kt @@ -0,0 +1,49 @@ +/* + * ============LICENSE_START======================================================= + * dcaegen2-collectors-veshv + * ================================================================================ + * Copyright (C) 2018 NOKIA + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.dcae.collectors.veshv.healthcheck.http + +import arrow.effects.IO +import ratpack.handling.Chain +import ratpack.http.Status +import ratpack.server.RatpackServer +import ratpack.server.ServerConfig + +/** + * @author Jakub Dudycz + * @since August 2018 + */ +class HealthCheckApiServer { + + fun start(port: Int): IO = IO { + RatpackServer + .start { + it + .serverConfig(ServerConfig.embedded().port(port).development(false)) + .handlers(this::configureHandlers) + } + } + + private fun configureHandlers(chain: Chain) { + chain + .get("healthcheck") { ctx -> + ctx.response.status(Status.OK).send() + } + } +} \ No newline at end of file -- cgit 1.2.3-korg