Protobuf:如何在proto中描述Option[Timestamp]

Protobuf: how to describe Option[Timestamp] in proto

如何在 *.proto 文件中针对以下情况 class 描述 Option[Timestamp]

case class User(name: String, created: Option[Timestamp] = None)

*.proto 包含:

   message User {
     string name = 1;
     how_to_describe_type_of_timestamp created = 2; // ???
   }

您似乎在使用 "proto3"(因为 name 上没有 requiredoptional),在这种情况下:一切 是可选的;也许只是:

syntax = "proto3";
import "google/protobuf/timestamp.proto";
message User {
     string name = 1;
     .google.protobuf.Timestamp created = 2;
}

如果这是 "proto2",那么大概是:

syntax = "proto2";
import "google/protobuf/timestamp.proto";
message User {
     required string name = 1;
     optional .google.protobuf.Timestamp created = 2;
}