-
Notifications
You must be signed in to change notification settings - Fork 20
Description
The java_multiple_files option is described like this in the protobuf documentation:
... For each
.protofile input, the compiler creates a wrapper.javafile containing a Java class which represents the.protofile itself.If the
.protofile contains a line like the following:option java_multiple_files = true;Then the compiler will also create separate
.javafiles for each of the classes/enums which it will generate for each top-level message, enumeration, and service declared in the.protofile.Otherwise (i.e. when the
java_multiple_filesoption is disabled; which is the default), the aforementioned wrapper class will also be used as an outer class, and the generated classes/enums for each top-level message, enumeration, and service declared in the.protofile will all be nested within the outer wrapper class. Thus the compiler will only generate a single.javafile for the entire.protofile.
The grpc-java and grpc-kotlin libraries both honor this option. For the given .proto file, the following outputs are produced by grpc-java:
syntax = "proto3";
package com.example;
option java_package = "com.example";
service EventService {
rpc Start (StartRequest) returns (StartResponse);
}
message StartRequest { }
message StartResponse { }With java_multiple_files = false
public suspend fun start(request: com.example.EventsServiceProto.StartRequest, headers: Metadata = Metadata()): com.example.EventsServiceProto.StartResponse = unaryRpc(
channel,
EventServiceGrpc.getStartMethod(),
request,
callOptions,
headers
)With java_multiple_files = true
public suspend fun start(request: com.example.StartRequest, headers: Metadata = Metadata()): com.example.StartResponse = unaryRpc(
channel,
EventServiceGrpc.getStartMethod(),
request,
callOptions,
headers
)However, protoc-gen-connect-kotlin generates identical output irrespective of the value of java_multiple_files:
public override suspend fun start(request: StartRequest, headers: Headers): ResponseMessage<StartResponse> = client.unary(
request,
headers,
MethodSpec(
"live.v1.EventService/Start",
com.example.StartRequest::class,
com.example.StartResponse::class,
),
)This means that the Request and Response classes are not found when trying to compile the application.
The connect-kotlin generator probably should check this option and generate compatible code.