Skip to content

Commit c38d91b

Browse files
feat: support zstd compression in PBJ GRPC (#770)
Signed-off-by: Anthony Petrov <anthony@swirldslabs.com>
1 parent 470ec7e commit c38d91b

18 files changed

Lines changed: 103 additions & 13 deletions

File tree

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ striving for.
3939
* ### [**Grpc Helidon** `pbj-grpc-helidon`](pbj-core/pbj-grpc-helidon/README.md)
4040
* ### [**Grpc Helidon Config** `pbj-grpc-helidon-config](pbj-core/pbj-grpc-helidon-config/README.md)
4141
* ### [**Grpc Client Helidon** `pbj-grpc-client-helidon`](pbj-core/pbj-grpc-client-helidon/README.md)
42+
* ### [**Grpc Common Code** `pbj-grpc-common`](pbj-core/pbj-grpc-client-helidon/README.md)
4243
* ### [**Integration Tests** `pbj-integration-tests`](pbj-integration-tests/README.md)
4344

4445
## Build Libraries
@@ -56,7 +57,5 @@ protobuf features and insure all the generated code is tested for hiero node use
5657
PBJ is a long term project with many goals. Here are some of the long term goals:
5758
* Support all Protobuf Features
5859
* Support new versions of Protobuf as possible
59-
* Generate GRPC Services
60-
* Built in GRPC-Web support
6160
* Auto mapping GRPC APIs to JSON REST APIs
6261
* JSON REST performance as good as GRPC

pbj-core/gradle/aggregation/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
dependencies {
33
published(project(":pbj-grpc-helidon"))
44
published(project(":pbj-grpc-client-helidon"))
5+
published(project(":pbj-grpc-common"))
56
}

pbj-core/hiero-dependency-versions/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ dependencies.constraints {
5555
excludes.add("org.antlr:antlr4")
5656
excludes.add("com.google.protobuf:protoc")
5757
excludes.add("io.grpc:protoc-gen-grpc-java")
58-
excludes.add("com.github.luben:zstd-jni")
5958
excludes.add("io.helidon.logging:helidon-logging-jul")
6059
}
6160

pbj-core/pbj-grpc-client-helidon/src/main/java/com/hedera/pbj/grpc/client/helidon/PbjGrpcClient.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: Apache-2.0
22
package com.hedera.pbj.grpc.client.helidon;
33

4+
import com.hedera.pbj.grpc.common.compression.ZstdGrpcTransformer;
45
import com.hedera.pbj.runtime.Codec;
56
import com.hedera.pbj.runtime.grpc.GrpcCall;
67
import com.hedera.pbj.runtime.grpc.GrpcClient;
@@ -30,6 +31,10 @@
3031
* A PBJ GRPC client that uses the Helidon WebClient and its HTTP2 client implementation to call remote GRPC services.
3132
*/
3233
public final class PbjGrpcClient implements GrpcClient, AutoCloseable {
34+
static {
35+
new ZstdGrpcTransformer().register("zstd");
36+
}
37+
3338
private final WebClient webClient;
3439
private final PbjGrpcClientConfig config;
3540

pbj-core/pbj-grpc-client-helidon/src/main/java/module-info.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
requires transitive com.hedera.pbj.runtime;
55
requires transitive io.helidon.common.tls;
66
requires transitive io.helidon.webclient.api;
7+
requires com.hedera.pbj.grpc.common;
78
requires io.helidon.builder.api;
89
requires io.helidon.common.buffers;
910
requires io.helidon.common.socket;

pbj-core/pbj-grpc-common/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# PBJ GRPC Helidon
2+
3+
This project produces a module with a common code used by both PBJ gRPC client and server
4+
that may not be suitable for the generic and lightweight `pbj-runtime` module due to extra dependencies.
5+
Examples of such code include:
6+
- common classes that depend on Helidon libraries,
7+
- code with external, potentially heavy dependencies, such as compressor/decompressor implementations
8+
9+
It produces `pbj-grpc-common-VERSION.jar`
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
plugins { id("org.hiero.gradle.module.library") }
3+
4+
description = "A library with common code used by both PBJ gRPC client and server"
5+
6+
testModuleInfo {
7+
requires("org.junit.jupiter.api")
8+
requiresStatic("java.annotation")
9+
}

pbj-integration-tests/src/jmh/java/com/hedera/pbj/integration/jmh/grpc/ZstdGrpcTransformer.java renamed to pbj-core/pbj-grpc-common/src/main/java/com/hedera/pbj/grpc/common/compression/ZstdGrpcTransformer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: Apache-2.0
2-
package com.hedera.pbj.integration.jmh.grpc;
2+
package com.hedera.pbj.grpc.common.compression;
33

44
import com.github.luben.zstd.ZstdInputStream;
55
import com.github.luben.zstd.ZstdOutputStream;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
/**
3+
* An implementation of additional compressors and decompressors for the PBJ gRPC client and server.
4+
*/
5+
package com.hedera.pbj.grpc.common.compression;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
/** PBJ gRPC client implementation. */
3+
module com.hedera.pbj.grpc.common {
4+
requires transitive com.hedera.pbj.runtime;
5+
requires com.github.luben.zstd_jni;
6+
7+
exports com.hedera.pbj.grpc.common.compression;
8+
}

0 commit comments

Comments
 (0)