-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move common to to shared artifact, adjust packages
- Loading branch information
Showing
58 changed files
with
1,223 additions
and
373 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...cloud/azure/spring/grpc/ecosystem/RequestResponseAzureGrpcEcosystemAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
package no.entur.logging.cloud.azure.spring.grpc.ecosystem; | ||
|
||
import no.entur.logging.cloud.spring.grpc.ecosystem.AbstractRequestResponseGrpcEcosystemSinkAutoConfiguration; | ||
import no.entur.logging.cloud.spring.grpc.ecosystem.RequestResponseGrpcEcosystemAutoConfiguration; | ||
import no.entur.logging.cloud.spring.rr.grpc.AbstractRequestResponseGrpcSinkAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.AutoConfigureBefore; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.PropertySource; | ||
|
||
@Configuration | ||
@PropertySource(value = "classpath:request-response.azure.properties", ignoreResourceNotFound = false) | ||
@AutoConfigureBefore(RequestResponseGrpcEcosystemAutoConfiguration.class) | ||
public class RequestResponseAzureGrpcEcosystemAutoConfiguration extends AbstractRequestResponseGrpcEcosystemSinkAutoConfiguration { | ||
public class RequestResponseAzureGrpcEcosystemAutoConfiguration extends AbstractRequestResponseGrpcSinkAutoConfiguration { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...gging/cloud/azure/spring/grpc/lognet/RequestResponseAzureGrpcLognetAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
package no.entur.logging.cloud.azure.spring.grpc.lognet; | ||
|
||
import no.entur.logging.cloud.spring.grpc.lognet.AbstractRequestResponseGrpcLognetSinkAutoConfiguration; | ||
import no.entur.logging.cloud.spring.grpc.lognet.RequestResponseGrpcLognetAutoConfiguration; | ||
import no.entur.logging.cloud.spring.rr.grpc.AbstractRequestResponseGrpcSinkAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.AutoConfigureBefore; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.PropertySource; | ||
|
||
@Configuration | ||
@PropertySource(value = "classpath:request-response.azure.properties", ignoreResourceNotFound = false) | ||
@AutoConfigureBefore(RequestResponseGrpcLognetAutoConfiguration.class) | ||
public class RequestResponseAzureGrpcLognetAutoConfiguration extends AbstractRequestResponseGrpcLognetSinkAutoConfiguration { | ||
|
||
public class RequestResponseAzureGrpcLognetAutoConfiguration extends AbstractRequestResponseGrpcSinkAutoConfiguration { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
examples/gcp-grpc-ecosystem-without-test-artifacts-example/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# gcp-grpc-ecosystem-without-test-artifacts-example | ||
Simple GRPC service example without test dependencies from this project. | ||
|
||
This emulates the deployed application (i.e. machine readable JSON). |
62 changes: 62 additions & 0 deletions
62
examples/gcp-grpc-ecosystem-without-test-artifacts-example/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
plugins { | ||
id 'org.springframework.boot' version '3.3.4' | ||
id "com.google.protobuf" version "0.9.4" | ||
} | ||
|
||
test { | ||
useJUnitPlatform { | ||
includeEngines 'junit-jupiter', 'junit-vintage' | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation project(':on-demand:on-demand-spring-boot-starter-grpc') | ||
implementation project(':gcp:spring-boot-starter-gcp-grpc-ecosystem') | ||
implementation project(':gcp:request-response-spring-boot-starter-gcp-grpc-ecosystem') | ||
implementation project(':trace:server:correlation-id-trace-grpc-netty') | ||
implementation project(':request-response:request-response-spring-boot-autoconfigure-grpc-ecosystem') | ||
|
||
implementation project(':trace:mdc-context-grpc-netty') | ||
|
||
implementation("io.grpc:grpc-api:$grpcVersion") | ||
implementation("io.grpc:grpc-core:$grpcVersion") | ||
implementation("io.grpc:grpc-context:$grpcVersion") | ||
implementation("io.grpc:grpc-stub:$grpcVersion") | ||
//implementation("io.grpc:grpc-inprocess:$grpcVersion") | ||
implementation("io.grpc:grpc-services:$grpcVersion") | ||
implementation("io.grpc:grpc-netty:$grpcVersion") | ||
implementation("io.grpc:grpc-util:$grpcVersion") | ||
implementation("org.springframework.boot:spring-boot-starter:${springBootVersion}") | ||
|
||
testImplementation("org.springframework.boot:spring-boot-starter-test:${springBootVersion}") | ||
|
||
// JUnit Jupiter API and TestEngine implementation | ||
testImplementation("org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}") | ||
testImplementation("org.junit.jupiter:junit-jupiter-engine:${junitJupiterVersion}") | ||
|
||
testImplementation ("com.google.truth:truth:${googleTruthVersion}") | ||
testImplementation ("com.google.truth.extensions:truth-java8-extension:${googleTruthVersion}") | ||
} | ||
|
||
sourceSets { | ||
test.java.srcDirs += "${protobuf.generatedFilesBaseDir}/test/java" | ||
test.java.srcDirs += "${protobuf.generatedFilesBaseDir}/test/grpc" | ||
} | ||
|
||
tasks.compileTestJava { dependsOn("generateTestProto") } | ||
|
||
protobuf { | ||
protoc { | ||
artifact = "com.google.protobuf:protoc:${grpcProtobufVersion}" | ||
} | ||
plugins { | ||
grpc { | ||
artifact = "io.grpc:protoc-gen-grpc-java:$grpcVersion" | ||
} | ||
} | ||
generateProtoTasks { | ||
all()*.plugins { | ||
grpc {} | ||
} | ||
} | ||
} |
177 changes: 177 additions & 0 deletions
177
...est-artifacts-example/src/main/java/no/entur/grpc/example/AbstractGreetingController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
package no.entur.grpc.example; | ||
|
||
|
||
import io.grpc.Metadata; | ||
import io.grpc.Status; | ||
import io.grpc.StatusRuntimeException; | ||
import org.entur.grpc.example.GreetingResponse; | ||
import org.entur.grpc.example.GreetingServiceGrpc; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.slf4j.MDC; | ||
|
||
import java.util.UUID; | ||
import java.util.concurrent.atomic.AtomicLong; | ||
|
||
public class AbstractGreetingController extends GreetingServiceGrpc.GreetingServiceImplBase { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractGreetingController.class); | ||
|
||
private final AtomicLong counter = new AtomicLong(); | ||
|
||
public void greeting1(org.entur.grpc.example.GreetingRequest request, | ||
io.grpc.stub.StreamObserver<GreetingResponse> responseObserver) { | ||
|
||
MDC.put("localKey", "value"); | ||
try { | ||
LOGGER.trace("Hello greeting / trace"); | ||
LOGGER.debug("Hello greeting / debug"); | ||
LOGGER.info("Hello greeting / info"); | ||
LOGGER.warn("Hello greeting / warn"); | ||
LOGGER.error("Hello greeting / error"); | ||
} finally { | ||
MDC.remove("localKey"); | ||
} | ||
|
||
responseObserver.onNext(createResponse(request)); | ||
responseObserver.onCompleted(); | ||
} | ||
|
||
public void exceptionLogging(org.entur.grpc.example.GreetingRequest request, io.grpc.stub.StreamObserver<GreetingResponse> responseObserver) { | ||
MDC.put("localKey", "value"); | ||
try { | ||
|
||
System.out.flush(); | ||
System.out.println("System out before endpoint logging"); | ||
|
||
LOGGER.trace("This message should be ignored / trace"); | ||
LOGGER.debug("This message should be ignored / debug"); | ||
LOGGER.info("This message should be delayed / info"); | ||
LOGGER.warn("This message should be logged / warn"); | ||
LOGGER.error("This message should be logged / error"); | ||
|
||
try { | ||
Thread.sleep(1000); | ||
} catch (InterruptedException e) { | ||
throw new RuntimeException(e); | ||
} | ||
System.out.println("System out after endpoint logging + 1000ms"); | ||
|
||
} finally { | ||
MDC.remove("localKey"); | ||
} | ||
|
||
Status status = Status.INVALID_ARGUMENT.withDescription("Mock exception"); | ||
throw status.asRuntimeException(); | ||
} | ||
|
||
/** | ||
* Multiple responses | ||
*/ | ||
|
||
public void greeting3(org.entur.grpc.example.GreetingRequest request, | ||
io.grpc.stub.StreamObserver<GreetingResponse> responseObserver) { | ||
|
||
String traceId = UUID.randomUUID().toString(); | ||
Metadata metadata = new Metadata(); | ||
metadata.put(Metadata.Key.of("x-correlation-id", Metadata.ASCII_STRING_MARSHALLER), traceId); | ||
|
||
LOGGER.trace("Hello greeting 3 / trace"); | ||
LOGGER.debug("Hello greeting 3 / debug"); | ||
LOGGER.info("Hello greeting 3 / info"); | ||
LOGGER.warn("Hello greeting 3 / warn"); | ||
for (int i = 0; i < 100; i++) { | ||
responseObserver.onNext(GreetingResponse.newBuilder().setMessage("Hello " + i).setStatus(counter.getAndIncrement()).build()); | ||
} | ||
responseObserver.onCompleted(); | ||
} | ||
|
||
public void noLogging(org.entur.grpc.example.GreetingRequest request, | ||
io.grpc.stub.StreamObserver<GreetingResponse> responseObserver) { | ||
|
||
LOGGER.trace("Hello no logging / trace"); | ||
LOGGER.debug("Hello no logging / debug"); | ||
LOGGER.info("Hello no logging / info"); | ||
LOGGER.warn("Hello no logging / warn"); | ||
|
||
responseObserver.onNext(createResponse(request)); | ||
responseObserver.onCompleted(); | ||
} | ||
|
||
public void fullLogging(org.entur.grpc.example.GreetingRequest request, | ||
io.grpc.stub.StreamObserver<GreetingResponse> responseObserver) { | ||
|
||
LOGGER.trace("Hello full logging"); | ||
LOGGER.debug("Hello full logging"); | ||
LOGGER.info("Hello full logging"); | ||
LOGGER.warn("Hello full logging"); | ||
|
||
responseObserver.onNext(createResponse(request)); | ||
responseObserver.onCompleted(); | ||
} | ||
|
||
public void summaryLogging(org.entur.grpc.example.GreetingRequest request, | ||
io.grpc.stub.StreamObserver<GreetingResponse> responseObserver) { | ||
|
||
LOGGER.trace("Hello summary logging"); | ||
LOGGER.debug("Hello summary logging"); | ||
LOGGER.info("Hello summary logging"); | ||
LOGGER.warn("Hello summary logging"); | ||
|
||
responseObserver.onNext(createResponse(request)); | ||
responseObserver.onCompleted(); | ||
} | ||
|
||
protected GreetingResponse createResponse(org.entur.grpc.example.GreetingRequest request) { | ||
StringBuilder builder = new StringBuilder("Hello"); | ||
|
||
long size = request.getReturnMessageSize(); | ||
if (size > 0) { | ||
builder.append(' '); | ||
for (long i = 0; i < request.getReturnMessageSize(); i++) { | ||
builder.append((char) ('a' + (int) (i % 27))); | ||
} | ||
} | ||
|
||
return GreetingResponse.newBuilder().setMessage(builder.toString()).setStatus(counter.incrementAndGet()).build(); | ||
} | ||
|
||
public void greetingWithResponseObserverOnErrorCall(org.entur.grpc.example.GreetingRequest request, | ||
io.grpc.stub.StreamObserver<GreetingResponse> responseObserver) { | ||
|
||
MDC.put("localKey", "value"); | ||
try { | ||
LOGGER.trace("Hello error / trace"); | ||
LOGGER.debug("Hello error / debug"); | ||
LOGGER.info("Hello error / info"); | ||
LOGGER.warn("Hello error / warn"); | ||
LOGGER.error("Hello error / error"); | ||
} finally { | ||
MDC.remove("localKey"); | ||
} | ||
|
||
responseObserver.onError(new StatusRuntimeException(Status.INTERNAL)); | ||
} | ||
|
||
public void greeting5(org.entur.grpc.example.GreetingRequest request, | ||
io.grpc.stub.StreamObserver<GreetingResponse> responseObserver) { | ||
|
||
MDC.put("localKey", "value"); | ||
try { | ||
LOGGER.trace("Hello greeting 5"); | ||
LOGGER.debug("Hello greeting 5"); | ||
LOGGER.info("Hello greeting 5"); | ||
LOGGER.warn("Hello greeting 5"); | ||
} finally { | ||
MDC.remove("localKey"); | ||
} | ||
|
||
GreetingResponse response = createResponse(request); | ||
|
||
// return same timestamp | ||
|
||
responseObserver.onNext(GreetingResponse.newBuilder(response).setTimestamp(request.getTimestamp()).build()); | ||
responseObserver.onCompleted(); | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
...m-without-test-artifacts-example/src/main/java/no/entur/grpc/example/DemoApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package no.entur.grpc.example; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class DemoApplication { | ||
public static void main(String[] args) { | ||
SpringApplication.run(DemoApplication.class, args); | ||
} | ||
} | ||
|
||
|
Oops, something went wrong.