aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/inbounds/selfservice-api
diff options
context:
space:
mode:
authorBrinda Santh <bs2796@att.com>2020-02-01 18:47:59 -0500
committerBrinda Santh <bs2796@att.com>2020-02-01 18:47:59 -0500
commitc6da9f5aaa7c29644ead22d5ba5fc8ef3ec5811a (patch)
tree60d328afa8a7516dec7a2da20bdcc76ee8644bf6 /ms/blueprintsprocessor/modules/inbounds/selfservice-api
parent5c094c6adc53d958b2079de67d9d26242e10d7ef (diff)
Expose rest API with non blocking call.
Convert Mono and Flux to coroutines Convert reactor mdc to coroutine mdc Issue-ID: CCSDK-2052 Signed-off-by: Brinda Santh <bs2796@att.com> Change-Id: Ic58c0b74866d28fd2d803b96626b08f8e8b2db56
Diffstat (limited to 'ms/blueprintsprocessor/modules/inbounds/selfservice-api')
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt13
1 files changed, 5 insertions, 8 deletions
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt
index 02d3f2026..8b268d6f8 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt
@@ -17,14 +17,14 @@
package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api
+import com.fasterxml.jackson.databind.JsonNode
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.ApiParam
-import kotlinx.coroutines.Dispatchers
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ACTION_MODE_ASYNC
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput
-import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.monoMdc
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.mdcWebCoroutineScope
import org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.utils.determineHttpStatusCode
import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
import org.onap.ccsdk.cds.controllerblueprints.core.logger
@@ -37,7 +37,6 @@ import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestMethod
import org.springframework.web.bind.annotation.ResponseBody
import org.springframework.web.bind.annotation.RestController
-import reactor.core.publisher.Mono
import java.util.concurrent.Phaser
import javax.annotation.PreDestroy
@@ -63,7 +62,7 @@ open class ExecutionServiceController {
)
@ResponseBody
@ApiOperation(value = "Health Check", hidden = true)
- fun executionServiceControllerHealthCheck() = monoMdc(Dispatchers.IO) {
+ suspend fun executionServiceControllerHealthCheck(): JsonNode = mdcWebCoroutineScope {
"Success".asJsonPrimitive()
}
@@ -76,16 +75,14 @@ open class ExecutionServiceController {
)
@ResponseBody
@PreAuthorize("hasRole('USER')")
- fun process(
+ suspend fun process(
@ApiParam(value = "ExecutionServiceInput payload.", required = true)
@RequestBody executionServiceInput: ExecutionServiceInput
- ):
- Mono<ResponseEntity<ExecutionServiceOutput>> = monoMdc(Dispatchers.IO) {
+ ): ResponseEntity<ExecutionServiceOutput> = mdcWebCoroutineScope {
if (executionServiceInput.actionIdentifiers.mode == ACTION_MODE_ASYNC) {
throw IllegalStateException("Can't process async request through the REST endpoint. Use gRPC for async processing.")
}
-
ph.register()
val processResult = executionServiceHandler.doProcess(executionServiceInput)
ph.arriveAndDeregister()