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

Server streaming case with an unary RPC does not create the streaming context #2637

Closed
BuddhiWathsala opened this issue Jan 31, 2022 · 0 comments · Fixed by ballerina-platform/module-ballerina-grpc#676
Assignees
Labels
module/grpc Team/PCM Protocol connector packages related issues Type/Bug

Comments

@BuddhiWathsala
Copy link
Contributor

Description:

Case 01

Check the following proto definition.

syntax = "proto3";

import "google/protobuf/empty.proto";

service Store {
  rpc getAlbums(google.protobuf.Empty) returns (stream Album);
  rpc storeAlbum(Album) returns (Album);
}

message Album {
    string id = 1;
    string title = 2;
    string artist = 3;
    float price = 4;
};

When I generate the stub using CLI, the generated stub does not contain the ContextAlbumStream definition.

$ bal grpc --input record_store.proto
$ bal build temp/record_store_pb.bal        
Compiling source
        record_store_pb.bal
ERROR [record_store_pb.bal:(51:57,51:75)] unknown type 'ContextAlbumStream'
ERROR [record_store_pb.bal:(57:26,57:70)] incompatible types: expected 'other', found 'stream<Album,ballerina/grpc:1.2.0:Error?>'

Case 02

However, when I re-organize the RPCs as below (i.e., make server streaming as the second definition), it works fine.

syntax = "proto3";

import "google/protobuf/empty.proto";

service Store {
  rpc storeAlbum(Album) returns (Album);
  rpc getAlbums(google.protobuf.Empty) returns (stream Album); // Change the order
}

message Album {
    string id = 1;
    string title = 2;
    string artist = 3;
    float price = 4;
};
$ bal grpc --input record_store.proto
$ bal build temp/record_store_pb.bal        
Compiling source
        record_store_pb.bal

Generating executable
        record_store_pb.jar

The workaround to prevent this issue would be to re-organize RPCs as in Case 02.

Affected Versions:
SL GA

OS, DB, other environment details and versions:

  • macOS
  • Java 11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/grpc Team/PCM Protocol connector packages related issues Type/Bug
Projects
None yet
2 participants