Skip to content

Instantly share code, notes, and snippets.

@vietj
Created March 31, 2025 13:49
Show Gist options
  • Save vietj/458bd7c5c056252169e52ae32a4973d3 to your computer and use it in GitHub Desktop.
Save vietj/458bd7c5c056252169e52ae32a4973d3 to your computer and use it in GitHub Desktop.

Proto centric

Given

service Greeter {
  rpc sayHello(HelloRequest) returns (HelloResponse);
}

message HelloRequest {
  string hello = 1;
}

message HelloResponse {
  string name = 1;
}

The gRPC plugin generates

// Common to client and service
@VertxGen
public interface Greeter {
  Future<HelloResponse> sayHello(HelloRequest request);
}

The service proxy processor generates

public class GreeterService implements Greeter {
  ...
}
public class GreeterClient implements Greeter {
  ...
}

Code centric

Given

// Common to client and service
@VertxGen
public interface Greeter {
  Future<HelloResponse> sayHello(HelloRequest request);
}
@DataObject
@ProtobufGen
public class HelloRequest {
}
@DataObject
@ProtobufGen
public class HelloResponse {
}

The annotation processor generates:

service Greeter {
  rpc sayHello(HelloRequest) returns (HelloResponse);
}

message HelloRequest {
  string hello = 1;
}

message HelloResponse {
  string name = 1;
}
public class GreeterService implements Greeter {
  ...
}
public class GreeterClient implements Greeter {
  ...
}

and the protobuf converters for the data objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment