From 04f5e0c9c3a7701620a2194a193e662405a21c78 Mon Sep 17 00:00:00 2001 From: fsoldatos <fsoldatos@ubitech.eu> Date: Mon, 15 Nov 2021 18:07:08 +0200 Subject: [PATCH] feat(automation): externalize grpc clients configuration --- src/automation/.env.example | 5 +++ .../context/ContextGatewayImpl.java | 3 +- .../automation/device/DeviceGatewayImpl.java | 3 +- .../src/main/resources/application.yaml | 11 +++++- .../grpc/context/ContextOuterClass.java | 36 +++++++++++++++++++ .../target/kubernetes/kubernetes.yml | 22 +++++++----- 6 files changed, 68 insertions(+), 12 deletions(-) diff --git a/src/automation/.env.example b/src/automation/.env.example index e69de29bb..35c4e0b97 100644 --- a/src/automation/.env.example +++ b/src/automation/.env.example @@ -0,0 +1,5 @@ +# Define the host for the Context Service +quarkus.kubernetes.env.vars.context-service-host=context + +# Define the host for the Device Service +quarkus.kubernetes.env.vars.device-service-host=device \ No newline at end of file diff --git a/src/automation/src/main/java/eu/teraflow/automation/context/ContextGatewayImpl.java b/src/automation/src/main/java/eu/teraflow/automation/context/ContextGatewayImpl.java index d52638267..6b0ff132e 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/context/ContextGatewayImpl.java +++ b/src/automation/src/main/java/eu/teraflow/automation/context/ContextGatewayImpl.java @@ -14,7 +14,8 @@ import javax.enterprise.context.ApplicationScoped; @ApplicationScoped public class ContextGatewayImpl implements ContextGateway { - @GrpcClient ContextService delegate; + @GrpcClient("context") + ContextService delegate; @Override public Multi<DeviceEvent> getDeviceEvents() { diff --git a/src/automation/src/main/java/eu/teraflow/automation/device/DeviceGatewayImpl.java b/src/automation/src/main/java/eu/teraflow/automation/device/DeviceGatewayImpl.java index 38f79eee0..78e72598e 100644 --- a/src/automation/src/main/java/eu/teraflow/automation/device/DeviceGatewayImpl.java +++ b/src/automation/src/main/java/eu/teraflow/automation/device/DeviceGatewayImpl.java @@ -14,7 +14,8 @@ import javax.enterprise.context.ApplicationScoped; @ApplicationScoped public class DeviceGatewayImpl implements DeviceGateway { - @GrpcClient DeviceService deviceDelegate; + @GrpcClient("device") + DeviceService deviceDelegate; @Override public Uni<eu.teraflow.automation.device.model.DeviceConfig> getInitialConfiguration( diff --git a/src/automation/src/main/resources/application.yaml b/src/automation/src/main/resources/application.yaml index e559876bf..2ea1ef12a 100644 --- a/src/automation/src/main/resources/application.yaml +++ b/src/automation/src/main/resources/application.yaml @@ -1,10 +1,15 @@ automation: - should-subscribe-to-context-component: false + should-subscribe-to-context-component: true quarkus: grpc: server: port: 9999 enable-reflection-service: true + clients: + context: + host: ${quarkus.kubernetes.env.vars.context-service-host} + device: + host: ${quarkus.kubernetes.env.vars.device-service-host} http: port: 8080 container-image: @@ -31,3 +36,7 @@ quarkus: grpc-server: host-port: 9999 container-port: 9999 + env: + vars: + context-service-host: context + device-service-host: device \ No newline at end of file diff --git a/src/automation/target/generated-sources/grpc/context/ContextOuterClass.java b/src/automation/target/generated-sources/grpc/context/ContextOuterClass.java index 473bfa689..21d845ecd 100644 --- a/src/automation/target/generated-sources/grpc/context/ContextOuterClass.java +++ b/src/automation/target/generated-sources/grpc/context/ContextOuterClass.java @@ -28708,11 +28708,19 @@ public final class ContextOuterClass { context.ContextOuterClass.EndPointIdOrBuilder getEndpointIdOrBuilder(); /** + * <pre> + *repeated kpi_sample_types.KpiSampleType kpi_sample_types = 3; + * </pre> + * * <code>string endpoint_type = 2;</code> * @return The endpointType. */ java.lang.String getEndpointType(); /** + * <pre> + *repeated kpi_sample_types.KpiSampleType kpi_sample_types = 3; + * </pre> + * * <code>string endpoint_type = 2;</code> * @return The bytes for endpointType. */ @@ -28845,6 +28853,10 @@ public final class ContextOuterClass { public static final int ENDPOINT_TYPE_FIELD_NUMBER = 2; private volatile java.lang.Object endpointType_; /** + * <pre> + *repeated kpi_sample_types.KpiSampleType kpi_sample_types = 3; + * </pre> + * * <code>string endpoint_type = 2;</code> * @return The endpointType. */ @@ -28862,6 +28874,10 @@ public final class ContextOuterClass { } } /** + * <pre> + *repeated kpi_sample_types.KpiSampleType kpi_sample_types = 3; + * </pre> + * * <code>string endpoint_type = 2;</code> * @return The bytes for endpointType. */ @@ -29333,6 +29349,10 @@ public final class ContextOuterClass { private java.lang.Object endpointType_ = ""; /** + * <pre> + *repeated kpi_sample_types.KpiSampleType kpi_sample_types = 3; + * </pre> + * * <code>string endpoint_type = 2;</code> * @return The endpointType. */ @@ -29349,6 +29369,10 @@ public final class ContextOuterClass { } } /** + * <pre> + *repeated kpi_sample_types.KpiSampleType kpi_sample_types = 3; + * </pre> + * * <code>string endpoint_type = 2;</code> * @return The bytes for endpointType. */ @@ -29366,6 +29390,10 @@ public final class ContextOuterClass { } } /** + * <pre> + *repeated kpi_sample_types.KpiSampleType kpi_sample_types = 3; + * </pre> + * * <code>string endpoint_type = 2;</code> * @param value The endpointType to set. * @return This builder for chaining. @@ -29381,6 +29409,10 @@ public final class ContextOuterClass { return this; } /** + * <pre> + *repeated kpi_sample_types.KpiSampleType kpi_sample_types = 3; + * </pre> + * * <code>string endpoint_type = 2;</code> * @return This builder for chaining. */ @@ -29391,6 +29423,10 @@ public final class ContextOuterClass { return this; } /** + * <pre> + *repeated kpi_sample_types.KpiSampleType kpi_sample_types = 3; + * </pre> + * * <code>string endpoint_type = 2;</code> * @param value The bytes for endpointType to set. * @return This builder for chaining. diff --git a/src/automation/target/kubernetes/kubernetes.yml b/src/automation/target/kubernetes/kubernetes.yml index c874443f6..a57486db6 100644 --- a/src/automation/target/kubernetes/kubernetes.yml +++ b/src/automation/target/kubernetes/kubernetes.yml @@ -3,8 +3,8 @@ apiVersion: v1 kind: Service metadata: annotations: - app.quarkus.io/commit-id: 285c0ca58a5b847c5bceed002b5e0fc0dcb5a28a - app.quarkus.io/build-timestamp: 2021-11-11 - 13:46:51 +0000 + app.quarkus.io/commit-id: 43db942bd5641ae293df75b65cd1eefd40b8085e + app.quarkus.io/build-timestamp: 2021-11-17 - 06:42:01 +0000 labels: app.kubernetes.io/name: automationservice app.kubernetes.io/version: 0.0.1 @@ -27,28 +27,28 @@ apiVersion: apps/v1 kind: Deployment metadata: annotations: - app.quarkus.io/commit-id: 285c0ca58a5b847c5bceed002b5e0fc0dcb5a28a - app.quarkus.io/build-timestamp: 2021-11-11 - 13:46:51 +0000 + app.quarkus.io/commit-id: 43db942bd5641ae293df75b65cd1eefd40b8085e + app.quarkus.io/build-timestamp: 2021-11-17 - 06:42:01 +0000 labels: app: automationservice - app.kubernetes.io/version: 0.0.1 app.kubernetes.io/name: automationservice + app.kubernetes.io/version: 0.0.1 name: automationservice spec: replicas: 1 selector: matchLabels: - app.kubernetes.io/version: 0.0.1 app.kubernetes.io/name: automationservice + app.kubernetes.io/version: 0.0.1 template: metadata: annotations: - app.quarkus.io/commit-id: 285c0ca58a5b847c5bceed002b5e0fc0dcb5a28a - app.quarkus.io/build-timestamp: 2021-11-11 - 13:46:51 +0000 + app.quarkus.io/commit-id: 43db942bd5641ae293df75b65cd1eefd40b8085e + app.quarkus.io/build-timestamp: 2021-11-17 - 06:42:01 +0000 labels: app: automationservice - app.kubernetes.io/version: 0.0.1 app.kubernetes.io/name: automationservice + app.kubernetes.io/version: 0.0.1 spec: containers: - env: @@ -56,6 +56,10 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace + - name: CONTEXT_SERVICE_HOST + value: context + - name: DEVICE_SERVICE_HOST + value: device image: registry.gitlab.com/teraflow-h2020/controller/automation:0.0.1 imagePullPolicy: Always livenessProbe: -- GitLab