I have a protobuf file in which I define multiple messages which all inherit the same trait (using option (scalapb.message).extends = "Event";
inside of message definition).
I would like to create a new message called MultiEvent which may contain sequence of any of the messages inherited from Event.
Event is defined as simple trait Event
in scala code.
The idea is to be able to send special message which contains multiple of messages at once.
syntax = "proto3";
import "scalapb/scalapb.proto";
package com.some.package;
message A {
option (scalapb.message).extends = "Event";
string name = 1;
}
message B {
option (scalapb.message).extends = "Event";
string field = 1;
}
message C {
option (scalapb.message).extends = "Event";
string otherField = 1;
}
message MultiEvent {
option (scalapb.message).extends = "Event";
repeated Event seq = 1; // this line is problematic
}
I got the error: "Event" is not defined.
.
Ideally from the code the field would be a simple Seq, which repeated provides, but it works only with scalar types.
I have found on internet that Any may be able to accomplish what I want, but I get errors when try to use it.
What is the usual way of solving problems like this? Enum? Conversion?
Thanks.