From 4e420fb1a5239e87ec597b3519eeb19a0ff17226 Mon Sep 17 00:00:00 2001 From: Ankur Shrivastava Date: Tue, 14 Nov 2023 16:35:23 +0800 Subject: [PATCH 1/3] updating protobuf modules * Enables building code on M1 macs * Updated protobuf used in project --- build.gradle | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index b07f290b7..90f5386da 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ buildscript { maven { url 'https://plugins.gradle.org/m2/' } } dependencies { - classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.17' + classpath 'com.google.protobuf:protobuf-gradle-plugin:0.9.4' classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.4.7" classpath "org.ajoberstar:gradle-git:1.6.0" } @@ -14,7 +14,7 @@ plugins { id 'idea' id 'checkstyle' id 'jacoco' - id "com.google.protobuf" version "0.8.17" + id "com.google.protobuf" version "0.9.4" id 'nebula.ospackage' version '8.6.3' id 'io.franzbecker.gradle-lombok' version '1.14' id 'maven-publish' @@ -58,8 +58,8 @@ private Properties loadEnv() { def mainClassName = "com.gotocompany.firehose.launch.Main" dependencies { - implementation group: 'com.google.protobuf', name: 'protobuf-java', version: '3.1.0' - implementation group: 'com.google.protobuf', name: 'protobuf-java-util', version: '3.1.0' + implementation group: 'com.google.protobuf', name: 'protobuf-java', version: '3.25.0' + implementation group: 'com.google.protobuf', name: 'protobuf-java-util', version: '3.25.0' implementation group: 'com.datadoghq', name: 'java-dogstatsd-client', version: '2.13.0' implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.2' implementation group: 'org.aeonbits.owner', name: 'owner', version: '1.0.9' @@ -117,11 +117,11 @@ dependencies { protobuf { generatedFilesBaseDir = "$projectDir/src/generated" protoc { - artifact = "com.google.protobuf:protoc:3.1.0" + artifact = "com.google.protobuf:protoc:3.25.0" } plugins { grpc { - artifact = "io.grpc:protoc-gen-grpc-java:1.0.3" + artifact = "io.grpc:protoc-gen-grpc-java:1.59.0" } } generateProtoTasks { From 62aca6048eb50e3017c294b8e72e5b2c3a1fd2e2 Mon Sep 17 00:00:00 2001 From: Ankur Shrivastava Date: Wed, 15 Nov 2023 13:42:42 +0800 Subject: [PATCH 2/3] adding support for authority header in gRPC sink --- .../com/gotocompany/firehose/config/GrpcSinkConfig.java | 2 ++ .../com/gotocompany/firehose/sink/grpc/GrpcSinkFactory.java | 4 ++-- .../gotocompany/firehose/sink/grpc/client/GrpcClient.java | 6 +++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gotocompany/firehose/config/GrpcSinkConfig.java b/src/main/java/com/gotocompany/firehose/config/GrpcSinkConfig.java index 9c2e61390..9568d5cc7 100644 --- a/src/main/java/com/gotocompany/firehose/config/GrpcSinkConfig.java +++ b/src/main/java/com/gotocompany/firehose/config/GrpcSinkConfig.java @@ -17,4 +17,6 @@ public interface GrpcSinkConfig extends AppConfig { @Config.Key("SINK_GRPC_RESPONSE_SCHEMA_PROTO_CLASS") String getSinkGrpcResponseSchemaProtoClass(); + @Config.Key("SINK_GRPC_SERVICE_AUTHORITY") + String getSinkGrpcServiceAuthority(); } diff --git a/src/main/java/com/gotocompany/firehose/sink/grpc/GrpcSinkFactory.java b/src/main/java/com/gotocompany/firehose/sink/grpc/GrpcSinkFactory.java index 9cf02ca0e..8930e3d04 100644 --- a/src/main/java/com/gotocompany/firehose/sink/grpc/GrpcSinkFactory.java +++ b/src/main/java/com/gotocompany/firehose/sink/grpc/GrpcSinkFactory.java @@ -25,8 +25,8 @@ public class GrpcSinkFactory { public static AbstractSink create(Map configuration, StatsDReporter statsDReporter, StencilClient stencilClient) { GrpcSinkConfig grpcConfig = ConfigFactory.create(GrpcSinkConfig.class, configuration); FirehoseInstrumentation firehoseInstrumentation = new FirehoseInstrumentation(statsDReporter, GrpcSinkFactory.class); - String grpcSinkConfig = String.format("\n\tService host: %s\n\tService port: %s\n\tMethod url: %s\n\tResponse proto schema: %s", - grpcConfig.getSinkGrpcServiceHost(), grpcConfig.getSinkGrpcServicePort(), grpcConfig.getSinkGrpcMethodUrl(), grpcConfig.getSinkGrpcResponseSchemaProtoClass()); + String grpcSinkConfig = String.format("\n\tService host: %s\n\tService port: %s\n\tAuthority: %s\n\tMethod url: %s\n\tResponse proto schema: %s", + grpcConfig.getSinkGrpcServiceHost(), grpcConfig.getSinkGrpcServicePort(), grpcConfig.getSinkGrpcServiceAuthority(), grpcConfig.getSinkGrpcMethodUrl(), grpcConfig.getSinkGrpcResponseSchemaProtoClass()); firehoseInstrumentation.logDebug(grpcSinkConfig); ManagedChannel managedChannel = ManagedChannelBuilder.forAddress(grpcConfig.getSinkGrpcServiceHost(), grpcConfig.getSinkGrpcServicePort()).usePlaintext().build(); diff --git a/src/main/java/com/gotocompany/firehose/sink/grpc/client/GrpcClient.java b/src/main/java/com/gotocompany/firehose/sink/grpc/client/GrpcClient.java index 44b11a591..879922c04 100644 --- a/src/main/java/com/gotocompany/firehose/sink/grpc/client/GrpcClient.java +++ b/src/main/java/com/gotocompany/firehose/sink/grpc/client/GrpcClient.java @@ -56,13 +56,17 @@ public DynamicMessage execute(byte[] logMessage, Headers headers) { Channel decoratedChannel = ClientInterceptors.intercept(managedChannel, MetadataUtils.newAttachHeadersInterceptor(metadata)); + CallOptions co = CallOptions.DEFAULT; + if (grpcSinkConfig.getSinkGrpcServiceAuthority() != null && !grpcSinkConfig.getSinkGrpcServiceAuthority().isEmpty()) { + co = co.withAuthority(grpcSinkConfig.getSinkGrpcServiceAuthority()); + } byte[] response = ClientCalls.blockingUnaryCall( decoratedChannel, MethodDescriptor.newBuilder(marshaller, marshaller) .setType(MethodDescriptor.MethodType.UNARY) .setFullMethodName(grpcSinkConfig.getSinkGrpcMethodUrl()) .build(), - CallOptions.DEFAULT, + co, logMessage); dynamicMessage = stencilClient.parse(grpcSinkConfig.getSinkGrpcResponseSchemaProtoClass(), response); From a81827c8765897c27e6c7951a43505aae04fa2a0 Mon Sep 17 00:00:00 2001 From: Ankur Shrivastava Date: Thu, 16 Nov 2023 13:35:03 +0800 Subject: [PATCH 3/3] updating version --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 90f5386da..381db030d 100644 --- a/build.gradle +++ b/build.gradle @@ -33,7 +33,7 @@ lombok { } group 'com.gotocompany' -version '0.9.2' +version '0.10.0' def projName = "firehose" @@ -101,7 +101,7 @@ dependencies { implementation platform('com.google.cloud:libraries-bom:20.5.0') implementation 'com.google.cloud:google-cloud-storage:2.20.1' implementation 'org.apache.logging.log4j:log4j-core:2.20.0' - implementation group: 'com.gotocompany', name: 'depot', version: '0.7.2' + implementation group: 'com.gotocompany', name: 'depot', version: '0.8.0' implementation group: 'com.networknt', name: 'json-schema-validator', version: '1.0.59' exclude group: 'org.slf4j' testImplementation group: 'junit', name: 'junit', version: '4.11'