Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve gRPC parser to allow complex types in optionValue #1350

Merged
merged 5 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,28 @@ packageStatement
// Option

optionStatement
: OPTION optionName EQ constant SEMI
: OPTION optionName EQ optionValue SEMI
;

optionName
: fullIdent
| LP fullIdent RP ( DOT fullIdent )?
;

optionValue
: constant
| LC optionFields? RC
;

optionFields
: optionField ( optionField )*
;

optionField
: optionName COLON optionValue
| optionName LC optionFields? RC
;

// Normal Field
fieldLabel
: OPTIONAL | REPEATED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
*/
package io.aklivity.zilla.runtime.binding.grpc.internal.config;

import java.util.Objects;
import java.util.Set;

import org.agrona.collections.ObjectHashSet;
import java.util.stream.Collectors;

import io.aklivity.zilla.runtime.binding.grpc.config.GrpcMethodConfig;
import io.aklivity.zilla.runtime.binding.grpc.config.GrpcServiceConfig;
Expand Down Expand Up @@ -46,15 +46,14 @@ public void exitServiceDef(
Protobuf3Parser.ServiceDefContext ctx)
{
String serviceName = String.format("%s.%s", package_, ctx.serviceName().getText());
final ObjectHashSet<GrpcMethodConfig> methods = new ObjectHashSet<>();

ctx.serviceElement().forEach(element ->
{
Protobuf3Parser.RpcContext rpc = element.rpc();
final Set<GrpcMethodConfig> methods = ctx.serviceElement().stream()
.map(Protobuf3Parser.ServiceElementContext::rpc)
.filter(Objects::nonNull)
.map(r -> r.rpcName().getText())
.map(GrpcMethodConfig::new)
.collect(Collectors.toUnmodifiableSet());

String method = rpc.rpcName().getText();
methods.add(new GrpcMethodConfig(method));
});
final GrpcServiceConfig service = new GrpcServiceConfig(serviceName, methods);
services.add(service);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ service EchoService
rpc EchoServerStream( EchoMessage) returns (stream EchoMessage);

rpc EchoStream(stream EchoMessage) returns (stream EchoMessage);

rpc ComplexMethod (EchoMessage) returns (EchoMessage) {
option (com.example.http) = {
delete : "/some/url"
additional_bindings {
delete: "/another/url"
}
};
}
}

message EchoMessage
Expand Down
Loading