diff options
author | 2019-11-18 19:06:58 -0500 | |
---|---|---|
committer | 2019-11-18 19:06:58 -0500 | |
commit | c38f351751334addb0bdb74f90344aa54cc23695 (patch) | |
tree | 8a66b489aa522a79e5fea876996945b9bb111af2 /ms/blueprintsprocessor/modules/commons/grpc-lib/src/main | |
parent | 31c2f7de56c5dd90de17ec3026510e5cc660ae67 (diff) |
Property based GRPC server service.
Issue-ID: CCSDK-1747
Signed-off-by: Brinda Santh <bs2796@att.com>
Change-Id: I948d4fac974a0d6d0c855ad4e24766a9ce6b7a6a
Diffstat (limited to 'ms/blueprintsprocessor/modules/commons/grpc-lib/src/main')
2 files changed, 28 insertions, 1 deletions
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcLibConfiguration.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcLibConfiguration.kt index 0ec049a3c..c37c6263a 100644 --- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcLibConfiguration.kt +++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcLibConfiguration.kt @@ -45,6 +45,8 @@ fun BluePrintDependencyService.grpcClientService(jsonNode: JsonNode): BluePrintG class GRPCLibConstants { companion object { const val SERVICE_BLUEPRINT_GRPC_LIB_PROPERTY = "blueprint-grpc-lib-property-service" + const val PROPERTY_GRPC_CLIENT_PREFIX = "blueprintsprocessor.grpcclient." + const val PROPERTY_GRPC_SERVER_PREFIX = "blueprintsprocessor.grpcserver." const val TYPE_TOKEN_AUTH = "token-auth" const val TYPE_BASIC_AUTH = "basic-auth" const val TYPE_TLS_AUTH = "tls-auth" diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyService.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyService.kt index fbc9ddd86..02d5cc695 100644 --- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyService.kt +++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyService.kt @@ -28,6 +28,18 @@ import org.springframework.stereotype.Service @Service(GRPCLibConstants.SERVICE_BLUEPRINT_GRPC_LIB_PROPERTY) open class BluePrintGrpcLibPropertyService(private var bluePrintPropertiesService: BluePrintPropertiesService) { + fun blueprintGrpcServerService(jsonNode: JsonNode): BluePrintGrpcServerService { + val grpcServerProperties = grpcServerProperties(jsonNode) + return blueprintGrpcServerService(grpcServerProperties) + } + + fun blueprintGrpcServerService(selector: String): BluePrintGrpcServerService { + val prefix = "${GRPCLibConstants.PROPERTY_GRPC_SERVER_PREFIX}$selector" + val grpcServerProperties = grpcServerProperties(prefix) + return blueprintGrpcServerService(grpcServerProperties) + } + + /** GRPC Server Lib Property Service */ fun grpcServerProperties(jsonNode: JsonNode): GrpcServerProperties { return when (val type = jsonNode.get("type").textValue()) { @@ -67,6 +79,19 @@ open class BluePrintGrpcLibPropertyService(private var bluePrintPropertiesServic return bluePrintPropertiesService.propertyBeanType(prefix, TLSAuthGrpcServerProperties::class.java) } + private fun blueprintGrpcServerService(grpcServerProperties: GrpcServerProperties) + : BluePrintGrpcServerService { + when (grpcServerProperties) { + is TLSAuthGrpcServerProperties -> { + return TLSAuthGrpcServerService(grpcServerProperties) + } + else -> { + throw BluePrintProcessorException("couldn't get grpc client service for properties $grpcServerProperties") + } + } + } + + /** GRPC Client Lib Property Service */ fun blueprintGrpcClientService(jsonNode: JsonNode): BluePrintGrpcClientService { @@ -75,7 +100,7 @@ open class BluePrintGrpcLibPropertyService(private var bluePrintPropertiesServic } fun blueprintGrpcClientService(selector: String): BluePrintGrpcClientService { - val prefix = "blueprintsprocessor.grpcclient.$selector" + val prefix = "${GRPCLibConstants.PROPERTY_GRPC_CLIENT_PREFIX}$selector" val restClientProperties = grpcClientProperties(prefix) return blueprintGrpcClientService(restClientProperties) } |