Skip to content

Commit

Permalink
RPC: add supervisor service & expose It as http/json endpoint via ser…
Browse files Browse the repository at this point in the history
…vice descriptor.

Add supervisor http/json client.
  • Loading branch information
mostroverkhov committed Nov 24, 2023
1 parent 0c880c1 commit baf83c4
Show file tree
Hide file tree
Showing 196 changed files with 2,259 additions and 171 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Message-Streams (RSocket-JVM) / GRPC interop example

This example demonstrates how `Message-Streams` services from [jauntsdn/RSocket-JVM](https://github.com/jauntsdn/rsocket-jvm)
interoperate with each other over multiple transports (tcp, unix sockets, websockets/http2) & with GRPC over http2. It also demonstrates
interoperate with each other over multiple transports (tcp, unix sockets, websockets/http2) & with GRPC, http/json over http2. It also demonstrates
how Message-Streams/RPC services may be decoupled from RSocket-JVM runtime (this includes transports, metrics, load estimators/circuit breakers).

`Message-Streams` is very fast GRPC-like & GRPC-compatible services on JVM with rich streaming models.
Expand All @@ -13,7 +13,7 @@ Each service & its RPC client/server bindings have API of different nature: grpc
or flavor of reactive: smallrye-mutiny, rxjava3, reactor-project.

Example application is comprised of 5 `Message-Streams` services (RSocket-JVM runtimes are stripped on this branch),
and one GRPC-java client:
plus GRPC & http/json clients:

* [Farmer](https://github.com/jauntsdn/rsocket-jvm-interop-examples/blob/feature/oss/messagestreams-reactor-service/src/main/java/com/jauntsdn/rsocket/trisocket/farm/Main.java) service (Message-Streams-RPC-reactor + TCP transport)

Expand All @@ -27,6 +27,8 @@ and one GRPC-java client:

* [Gourmet](https://github.com/jauntsdn/rsocket-jvm-interop-examples/blob/feature/oss/grpc-client/src/main/java/com/jauntsdn/rsocket/trisocket/gourmet/Main.java) client (GRPC-java)

* [Supervisor](https://github.com/jauntsdn/rsocket-jvm-interop-examples/blob/feature/oss/grpc-client/src/main/java/com/jauntsdn/rsocket/trisocket/supervisor/Main.java) client (http/json)

![services](readme/mstreams-interop-svcs.png "services")

### Build
Expand Down
8 changes: 5 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group=com.jauntsdn.rsocket
version=1.5.1
version=1.5.2

googleJavaFormatPluginVersion=0.9
dependencyManagementPluginVersion=1.1.0
Expand All @@ -8,10 +8,12 @@ gitPluginVersion=0.13.0
osDetectorPluginVersion=1.7.3
versionsPluginVersion=0.45.0

rsocketVersion=1.5.1
rsocketVersion=1.5.2
slf4jVersion=1.7.36
logbackVersion=1.2.12
grpcVersion=1.57.1
grpcVersion=1.59.0
jacksonVersion=2.15.3
reactorNettyVersion=1.1.12

org.gradle.parallel=true
org.gradle.configureondemand=true
4 changes: 4 additions & 0 deletions gradle/dependency-management.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ subprojects {
dependency "io.grpc:grpc-protobuf:${grpcVersion}"
dependency "io.grpc:grpc-stub:${grpcVersion}"
dependency "io.grpc:grpc-netty-shaded:${grpcVersion}"

/*http client*/
dependency "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}"
dependency "io.projectreactor.netty:reactor-netty-http:${reactorNettyVersion}"
}
}
}
25 changes: 13 additions & 12 deletions grpc-client/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
ch.qos.logback:logback-classic:1.2.12=runtimeClasspath
ch.qos.logback:logback-core:1.2.12=runtimeClasspath
com.google.android:annotations:4.1.1.4=compileProtoPath,runtimeClasspath,testCompileProtoPath
com.google.api.grpc:proto-google-common-protos:2.17.0=compileClasspath,compileProtoPath,runtimeClasspath,testCompileClasspath,testCompileProtoPath
com.google.api.grpc:proto-google-common-protos:2.22.0=compileClasspath,compileProtoPath,runtimeClasspath,testCompileClasspath,testCompileProtoPath
com.google.code.findbugs:jsr305:1.3.9=googleJavaFormat1.6
com.google.code.findbugs:jsr305:3.0.2=compileClasspath,compileProtoPath,runtimeClasspath,testCompileClasspath,testCompileProtoPath
com.google.code.gson:gson:2.10.1=compileProtoPath,runtimeClasspath,testCompileProtoPath
com.google.errorprone:error_prone_annotations:2.0.18=googleJavaFormat1.6
com.google.errorprone:error_prone_annotations:2.18.0=compileClasspath,compileProtoPath,runtimeClasspath,testCompileClasspath,testCompileProtoPath
com.google.errorprone:error_prone_annotations:2.20.0=compileClasspath,compileProtoPath,runtimeClasspath,testCompileClasspath,testCompileProtoPath
com.google.errorprone:javac-shaded:9+181-r4173-1=googleJavaFormat1.6
com.google.googlejavaformat:google-java-format:1.6=googleJavaFormat1.6
com.google.guava:failureaccess:1.0.1=compileClasspath,compileProtoPath,runtimeClasspath,testCompileClasspath,testCompileProtoPath
Expand All @@ -18,16 +18,17 @@ com.google.guava:guava:32.0.1-android=compileClasspath,compileProtoPath,runtimeC
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=compileClasspath,compileProtoPath,runtimeClasspath,testCompileClasspath,testCompileProtoPath
com.google.j2objc:j2objc-annotations:1.1=googleJavaFormat1.6
com.google.j2objc:j2objc-annotations:2.8=compileClasspath,compileProtoPath,runtimeClasspath,testCompileClasspath,testCompileProtoPath
com.google.protobuf:protobuf-java:3.24.2=compileClasspath,compileProtoPath,runtimeClasspath,testCompileClasspath,testCompileProtoPath
com.google.protobuf:protoc:3.24.2=protobufToolsLocator_protoc
io.grpc:grpc-api:1.57.1=compileClasspath,compileProtoPath,runtimeClasspath,testCompileClasspath,testCompileProtoPath
io.grpc:grpc-context:1.57.1=compileProtoPath,runtimeClasspath,testCompileProtoPath
io.grpc:grpc-core:1.57.1=compileClasspath,compileProtoPath,runtimeClasspath,testCompileClasspath,testCompileProtoPath
io.grpc:grpc-netty-shaded:1.57.1=compileClasspath,compileProtoPath,runtimeClasspath,testCompileClasspath,testCompileProtoPath
io.grpc:grpc-protobuf-lite:1.57.1=compileClasspath,compileProtoPath,runtimeClasspath,testCompileClasspath,testCompileProtoPath
io.grpc:grpc-protobuf:1.57.1=compileClasspath,compileProtoPath,runtimeClasspath,testCompileClasspath,testCompileProtoPath
io.grpc:grpc-stub:1.57.1=compileClasspath,compileProtoPath,runtimeClasspath,testCompileClasspath,testCompileProtoPath
io.grpc:protoc-gen-grpc-java:1.57.1=protobufToolsLocator_grpc
com.google.protobuf:protobuf-java:3.25.0=compileClasspath,compileProtoPath,runtimeClasspath,testCompileClasspath,testCompileProtoPath
com.google.protobuf:protoc:3.25.0=protobufToolsLocator_protoc
io.grpc:grpc-api:1.59.0=compileClasspath,compileProtoPath,runtimeClasspath,testCompileClasspath,testCompileProtoPath
io.grpc:grpc-context:1.59.0=compileProtoPath,runtimeClasspath,testCompileProtoPath
io.grpc:grpc-core:1.59.0=compileClasspath,compileProtoPath,runtimeClasspath,testCompileClasspath,testCompileProtoPath
io.grpc:grpc-netty-shaded:1.59.0=compileClasspath,compileProtoPath,runtimeClasspath,testCompileClasspath,testCompileProtoPath
io.grpc:grpc-protobuf-lite:1.59.0=compileClasspath,compileProtoPath,runtimeClasspath,testCompileClasspath,testCompileProtoPath
io.grpc:grpc-protobuf:1.59.0=compileClasspath,compileProtoPath,runtimeClasspath,testCompileClasspath,testCompileProtoPath
io.grpc:grpc-stub:1.59.0=compileClasspath,compileProtoPath,runtimeClasspath,testCompileClasspath,testCompileProtoPath
io.grpc:grpc-util:1.59.0=compileProtoPath,runtimeClasspath,testCompileProtoPath
io.grpc:protoc-gen-grpc-java:1.59.0=protobufToolsLocator_grpc
io.perfmark:perfmark-api:0.26.0=compileProtoPath,runtimeClasspath,testCompileProtoPath
javax.annotation:javax.annotation-api:1.3.2=compileClasspath,compileProtoPath,runtimeClasspath,testCompileClasspath,testCompileProtoPath
org.checkerframework:checker-qual:3.33.0=compileClasspath,compileProtoPath,runtimeClasspath,testCompileClasspath,testCompileProtoPath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
*/
@javax.annotation.Generated(
value = "by gRPC proto compiler (version 1.57.1)",
value = "by gRPC proto compiler (version 1.59.0)",
comments = "Source: service.proto")
@io.grpc.stub.annotations.GrpcGenerated
public final class ChefGrpc {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
*/
@javax.annotation.Generated(
value = "by gRPC proto compiler (version 1.57.1)",
value = "by gRPC proto compiler (version 1.59.0)",
comments = "Source: service.proto")
@io.grpc.stub.annotations.GrpcGenerated
public final class FarmerGrpc {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
*/
@javax.annotation.Generated(
value = "by gRPC proto compiler (version 1.57.1)",
value = "by gRPC proto compiler (version 1.59.0)",
comments = "Source: service.proto")
@io.grpc.stub.annotations.GrpcGenerated
public final class KitchenGrpc {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
*/
@javax.annotation.Generated(
value = "by gRPC proto compiler (version 1.57.1)",
value = "by gRPC proto compiler (version 1.59.0)",
comments = "Source: service.proto")
@io.grpc.stub.annotations.GrpcGenerated
public final class RecipesGrpc {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
*/
@javax.annotation.Generated(
value = "by gRPC proto compiler (version 1.57.1)",
value = "by gRPC proto compiler (version 1.59.0)",
comments = "Source: service.proto")
@io.grpc.stub.annotations.GrpcGenerated
public final class RoundsmanGrpc {
Expand Down
1 change: 1 addition & 0 deletions grpc-client/src/generated/main/java/trisocket/Dish.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions grpc-client/src/generated/main/java/trisocket/Meat.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions grpc-client/src/generated/main/java/trisocket/Order.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions grpc-client/src/generated/main/java/trisocket/Pan.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions grpc-client/src/generated/main/java/trisocket/Recipe.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions grpc-client/src/generated/main/java/trisocket/Veggie.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
import io.grpc.stub.ClientCallStreamObserver;
import io.grpc.stub.ClientResponseObserver;
import java.net.InetSocketAddress;
import java.util.concurrent.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -35,7 +39,7 @@ public static void main(String[] args) throws Exception {
NettyChannelBuilder.forAddress(new InetSocketAddress(kitchenHost, kitchenPort))
.compressorRegistry(compressorRegistry)
.decompressorRegistry(decompressorRegistry)
.usePlaintext()
.sslContext(Security.clientLocalSslContext())
.flowControlWindow(100_000)
.build();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Copyright 2020 - present Maksym Ostroverkhov.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.jauntsdn.rsocket.trisocket.gourmet;

import io.grpc.netty.shaded.io.netty.handler.ssl.ApplicationProtocolConfig;
import io.grpc.netty.shaded.io.netty.handler.ssl.ApplicationProtocolNames;
import io.grpc.netty.shaded.io.netty.handler.ssl.OpenSsl;
import io.grpc.netty.shaded.io.netty.handler.ssl.SslContext;
import io.grpc.netty.shaded.io.netty.handler.ssl.SslContextBuilder;
import io.grpc.netty.shaded.io.netty.handler.ssl.SslProvider;
import io.grpc.netty.shaded.io.netty.handler.ssl.SupportedCipherSuiteFilter;
import io.grpc.netty.shaded.io.netty.handler.ssl.util.InsecureTrustManagerFactory;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import javax.net.ssl.SSLException;

public final class Security {

public static SslContext clientLocalSslContext() {
try {
return clientSslContextBuilder().trustManager(InsecureTrustManagerFactory.INSTANCE).build();
} catch (SSLException e) {
throw new RuntimeException("TLS error", e);
}
}

private static SslContextBuilder clientSslContextBuilder() {
return SslContextBuilder.forClient()
.protocols("TLSv1.3")
.sslProvider(sslProvider())
.applicationProtocolConfig(alpnConfig())
.ciphers(CIPHERS, SupportedCipherSuiteFilter.INSTANCE);
}

private static ApplicationProtocolConfig alpnConfig() {
return new ApplicationProtocolConfig(
ApplicationProtocolConfig.Protocol.ALPN,
ApplicationProtocolConfig.SelectorFailureBehavior.NO_ADVERTISE,
ApplicationProtocolConfig.SelectedListenerFailureBehavior.ACCEPT,
ApplicationProtocolNames.HTTP_2);
}

private static SslProvider sslProvider() {
final SslProvider sslProvider;
if (OpenSsl.isAvailable()) {
sslProvider = SslProvider.OPENSSL_REFCNT;
} else {
sslProvider = SslProvider.JDK;
}
return sslProvider;
}

private static final List<String> CIPHERS =
Collections.unmodifiableList(
Arrays.asList(
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256",
"TLS_AES_128_GCM_SHA256",
"TLS_AES_256_GCM_SHA384",
"TLS_CHACHA20_POLY1305_SHA256"));
}
Binary file added grpc-client/src/main/resources/localhost.p12
Binary file not shown.
25 changes: 25 additions & 0 deletions http-client/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
plugins {
id "application"
}

description = "jauntsdn-trisocket: http client"

dependencies {
implementation "io.projectreactor.netty:reactor-netty-http"
implementation "com.fasterxml.jackson.core:jackson-databind"
implementation "org.slf4j:slf4j-api"

runtimeOnly "ch.qos.logback:logback-classic"
}

compileJava {
sourceCompatibility = 11
targetCompatibility = 11
}

mainClassName = "com.jauntsdn.rsocket.trisocket.supervisor.Main"

task runMain(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
mainClass = mainClassName
}
Loading

0 comments on commit baf83c4

Please sign in to comment.