Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions bleep.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,87 @@ projects:
sources:
- ./generated-and-checked-in
- ./src
testers/grpc/java:
dependencies:
- com.google.protobuf:protobuf-java:4.29.3
- com.novocode:junit-interface:0.11
- io.grpc:grpc-netty-shaded:1.69.0
- io.grpc:grpc-protobuf:1.69.0
- io.grpc:grpc-stub:1.69.0
- io.grpc:grpc-testing:1.69.0
- io.grpc:grpc-inprocess:1.69.0
- junit:junit:4.13.2
dependsOn: foundations-jdbc
folder: ./testers/grpc/java
isTestProject: true
java:
options: -proc:none
platform:
name: jvm
sources:
- ./generated-and-checked-in
- ./src/java
testers/grpc/scala:
dependencies:
- com.google.protobuf:protobuf-java:4.29.3
- com.novocode:junit-interface:0.11
- io.grpc:grpc-netty-shaded:1.69.0
- io.grpc:grpc-protobuf:1.69.0
- io.grpc:grpc-stub:1.69.0
- io.grpc:grpc-testing:1.69.0
- io.grpc:grpc-inprocess:1.69.0
- junit:junit:4.13.2
dependsOn: foundations-jdbc
extends: template-scala-3
isTestProject: true
sources:
- ./generated-and-checked-in
- ./src/scala
testers/grpc/java-spring:
dependencies:
- com.google.protobuf:protobuf-java:4.29.3
- com.novocode:junit-interface:0.11
- io.grpc:grpc-netty-shaded:1.69.0
- io.grpc:grpc-protobuf:1.69.0
- io.grpc:grpc-stub:1.69.0
- io.grpc:grpc-testing:1.69.0
- io.grpc:grpc-inprocess:1.69.0
- junit:junit:4.13.2
- org.springframework.grpc:spring-grpc-core:0.3.0
- org.springframework:spring-context:6.2.1
dependsOn: foundations-jdbc
folder: ./testers/grpc/java-spring
isTestProject: true
java:
options: -proc:none
platform:
name: jvm
sources:
- ./generated-and-checked-in
- ./src/java
testers/grpc/java-quarkus:
dependencies:
- com.google.protobuf:protobuf-java:4.29.3
- com.novocode:junit-interface:0.11
- io.grpc:grpc-netty-shaded:1.69.0
- io.grpc:grpc-protobuf:1.69.0
- io.grpc:grpc-stub:1.69.0
- io.grpc:grpc-testing:1.69.0
- io.grpc:grpc-inprocess:1.69.0
- io.quarkus:quarkus-arc:3.17.2
- io.quarkus:quarkus-grpc:3.17.2
- jakarta.enterprise:jakarta.enterprise.cdi-api:4.1.0
- junit:junit:4.13.2
dependsOn: foundations-jdbc
folder: ./testers/grpc/java-quarkus
isTestProject: true
java:
options: -proc:none
platform:
name: jvm
sources:
- ./generated-and-checked-in
- ./src/java
tests:
dependencies: org.scalatest::scalatest:3.2.18
dependsOn: typr
Expand All @@ -667,6 +748,9 @@ projects:
- com.microsoft.sqlserver:mssql-jdbc:12.8.1.jre11
- com.oracle.database.jdbc:ojdbc11:23.6.0.24.10
- com.typesafe.play::play-json:2.10.6
- com.google.protobuf:protobuf-java:4.29.3
- io.grpc:grpc-protobuf:1.69.0
- io.grpc:grpc-stub:1.69.0
- org.apache.avro:avro:1.12.0
- for3Use213: true
module: io.get-coursier::coursier:2.1.24
Expand Down Expand Up @@ -738,6 +822,9 @@ scripts:
generate-avro-test:
main: scripts.GenerateAvroTest
project: typr-scripts
generate-grpc-test:
main: scripts.GenerateGrpcTest
project: typr-scripts
generate-db2:
main: scripts.GeneratedDb2
project: typr-scripts
Expand Down
6 changes: 6 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ project(":testers:avro:kotlin-json").projectDir = file("testers/avro/kotlin-json
include("testers:avro:kotlin-quarkus-mutiny")
project(":testers:avro:kotlin-quarkus-mutiny").projectDir = file("testers/avro/kotlin-quarkus-mutiny")

// gRPC Kotlin testers
include("testers:grpc:kotlin")
project(":testers:grpc:kotlin").projectDir = file("testers/grpc/kotlin")
include("testers:grpc:kotlin-quarkus")
project(":testers:grpc:kotlin-quarkus").projectDir = file("testers/grpc/kotlin-quarkus")

// OpenAPI Kotlin testers
include("testers:openapi:kotlin:jaxrs")
project(":testers:openapi:kotlin:jaxrs").projectDir = file("testers/openapi/kotlin/jaxrs")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.example.grpc;

import com.google.protobuf.CodedInputStream;
import com.google.protobuf.CodedOutputStream;
import com.google.protobuf.WireFormat;
import io.grpc.MethodDescriptor.Marshaller;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;

public record BankTransfer(String accountNumber, String routingNumber) {
public BankTransfer withAccountNumber(String accountNumber) {
return new BankTransfer(accountNumber, routingNumber);
}

public BankTransfer withRoutingNumber(String routingNumber) {
return new BankTransfer(accountNumber, routingNumber);
}

public static Marshaller<BankTransfer> MARSHALLER =
new Marshaller<BankTransfer>() {
@Override
public InputStream stream(BankTransfer value) {
var bytes = new byte[value.getSerializedSize()];
var cos = CodedOutputStream.newInstance(bytes);
try {
value.writeTo(cos);
cos.flush();
} catch (IOException e) {
throw new RuntimeException(e);
}
return new ByteArrayInputStream(bytes);
}

@Override
public BankTransfer parse(InputStream stream) {
try {
return BankTransfer.parseFrom(CodedInputStream.newInstance(stream));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
};

public static BankTransfer parseFrom(CodedInputStream input) throws IOException {
String accountNumber = "";
String routingNumber = "";
while (!input.isAtEnd()) {
var tag = input.readTag();
if (WireFormat.getTagFieldNumber(tag) == 1) {
accountNumber = input.readString();
} else if (WireFormat.getTagFieldNumber(tag) == 2) {
routingNumber = input.readString();
} else {
input.skipField(tag);
}
;
}
;
return new BankTransfer(accountNumber, routingNumber);
}

public Integer getSerializedSize() {
Integer size = 0;
size = size + CodedOutputStream.computeStringSize(1, this.accountNumber());
size = size + CodedOutputStream.computeStringSize(2, this.routingNumber());
return size;
}

public void writeTo(CodedOutputStream output) throws IOException {
output.writeString(1, this.accountNumber());
output.writeString(2, this.routingNumber());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package com.example.grpc;

import com.google.protobuf.CodedInputStream;
import com.google.protobuf.CodedOutputStream;
import com.google.protobuf.WireFormat;
import io.grpc.MethodDescriptor.Marshaller;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.time.Instant;

public record ChatMessage(String sender, String content, Instant sentAt) {
public ChatMessage withSender(String sender) {
return new ChatMessage(sender, content, sentAt);
}

public ChatMessage withContent(String content) {
return new ChatMessage(sender, content, sentAt);
}

public ChatMessage withSentAt(Instant sentAt) {
return new ChatMessage(sender, content, sentAt);
}

public static Marshaller<ChatMessage> MARSHALLER =
new Marshaller<ChatMessage>() {
@Override
public InputStream stream(ChatMessage value) {
var bytes = new byte[value.getSerializedSize()];
var cos = CodedOutputStream.newInstance(bytes);
try {
value.writeTo(cos);
cos.flush();
} catch (IOException e) {
throw new RuntimeException(e);
}
return new ByteArrayInputStream(bytes);
}

@Override
public ChatMessage parse(InputStream stream) {
try {
return ChatMessage.parseFrom(CodedInputStream.newInstance(stream));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
};

public static ChatMessage parseFrom(CodedInputStream input) throws IOException {
String sender = "";
String content = "";
Instant sentAt = Instant.EPOCH;
while (!input.isAtEnd()) {
var tag = input.readTag();
if (WireFormat.getTagFieldNumber(tag) == 1) {
sender = input.readString();
} else if (WireFormat.getTagFieldNumber(tag) == 2) {
content = input.readString();
} else if (WireFormat.getTagFieldNumber(tag) == 3) {
var _length = input.readRawVarint32();
var _oldLimit = input.pushLimit(_length);
var _tsSeconds = 0L;
var _tsNanos = 0;
while (!input.isAtEnd()) {
var _tsTag = input.readTag();
if (WireFormat.getTagFieldNumber(_tsTag) == 1) {
_tsSeconds = input.readInt64();
} else if (WireFormat.getTagFieldNumber(_tsTag) == 2) {
_tsNanos = input.readInt32();
} else {
input.skipField(_tsTag);
}
;
}
;
sentAt = Instant.ofEpochSecond(_tsSeconds, (long) (_tsNanos));
input.popLimit(_oldLimit);
;
} else {
input.skipField(tag);
}
;
}
;
return new ChatMessage(sender, content, sentAt);
}

public Integer getSerializedSize() {
Integer size = 0;
size = size + CodedOutputStream.computeStringSize(1, this.sender());
size = size + CodedOutputStream.computeStringSize(2, this.content());
size =
size
+ CodedOutputStream.computeTagSize(3)
+ CodedOutputStream.computeUInt32SizeNoTag(
CodedOutputStream.computeInt64Size(1, this.sentAt().getEpochSecond())
+ CodedOutputStream.computeInt32Size(2, this.sentAt().getNano()))
+ CodedOutputStream.computeInt64Size(1, this.sentAt().getEpochSecond())
+ CodedOutputStream.computeInt32Size(2, this.sentAt().getNano());
return size;
}

public void writeTo(CodedOutputStream output) throws IOException {
output.writeString(1, this.sender());
output.writeString(2, this.content());
output.writeTag(3, 2);
output.writeUInt32NoTag(
CodedOutputStream.computeInt64Size(1, this.sentAt().getEpochSecond())
+ CodedOutputStream.computeInt32Size(2, this.sentAt().getNano()));
output.writeInt64(1, this.sentAt().getEpochSecond());
output.writeInt32(2, this.sentAt().getNano());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.example.grpc;

import com.google.protobuf.CodedInputStream;
import com.google.protobuf.CodedOutputStream;
import com.google.protobuf.WireFormat;
import io.grpc.MethodDescriptor.Marshaller;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;

public record CreateOrderRequest(Order order) {
public CreateOrderRequest withOrder(Order order) {
return new CreateOrderRequest(order);
}

public static Marshaller<CreateOrderRequest> MARSHALLER =
new Marshaller<CreateOrderRequest>() {
@Override
public InputStream stream(CreateOrderRequest value) {
var bytes = new byte[value.getSerializedSize()];
var cos = CodedOutputStream.newInstance(bytes);
try {
value.writeTo(cos);
cos.flush();
} catch (IOException e) {
throw new RuntimeException(e);
}
return new ByteArrayInputStream(bytes);
}

@Override
public CreateOrderRequest parse(InputStream stream) {
try {
return CreateOrderRequest.parseFrom(CodedInputStream.newInstance(stream));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
};

public static CreateOrderRequest parseFrom(CodedInputStream input) throws IOException {
Order order = null;
while (!input.isAtEnd()) {
var tag = input.readTag();
if (WireFormat.getTagFieldNumber(tag) == 1) {
var _length = input.readRawVarint32();
var _oldLimit = input.pushLimit(_length);
order = Order.parseFrom(input);
input.popLimit(_oldLimit);
;
} else {
input.skipField(tag);
}
;
}
;
return new CreateOrderRequest(order);
}

public Integer getSerializedSize() {
Integer size = 0;
if (!this.order().equals(null)) {
size =
size
+ CodedOutputStream.computeTagSize(1)
+ CodedOutputStream.computeUInt32SizeNoTag(this.order().getSerializedSize())
+ this.order().getSerializedSize();
}
return size;
}

public void writeTo(CodedOutputStream output) throws IOException {
if (!this.order().equals(null)) {
output.writeTag(1, 2);
output.writeUInt32NoTag(this.order().getSerializedSize());
this.order().writeTo(output);
;
}
}
}
Loading
Loading