Use string for the timestamp, proto uses this under the hood anyway

https://github.com/grpc-ecosystem/grpc-gateway/issues/438
This commit is contained in:
Marc Di Luzio 2020-07-09 19:38:23 +01:00
parent b748846c55
commit 30ca488890
4 changed files with 6 additions and 7 deletions

View file

@ -94,7 +94,7 @@ func (s *Server) Status(ctx context.Context, req *rove.StatusRequest) (response
for _, log := range rover.Logs { for _, log := range rover.Logs {
logs = append(logs, &rove.Log{ logs = append(logs, &rove.Log{
Text: log.Text, Text: log.Text,
Time: log.Time.Unix(), Time: fmt.Sprintf("%d", log.Time.Unix()), // proto uses strings under the hood for 64bit ints anyway
}) })
} }

View file

@ -504,7 +504,7 @@ type Log struct {
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
// The unix timestamp of the log // The unix timestamp of the log
Time int64 `protobuf:"varint,1,opt,name=time,proto3" json:"time,omitempty"` Time string `protobuf:"bytes,1,opt,name=time,proto3" json:"time,omitempty"`
// The text of the log // The text of the log
Text string `protobuf:"bytes,2,opt,name=text,proto3" json:"text,omitempty"` Text string `protobuf:"bytes,2,opt,name=text,proto3" json:"text,omitempty"`
} }
@ -541,11 +541,11 @@ func (*Log) Descriptor() ([]byte, []int) {
return file_rove_rove_proto_rawDescGZIP(), []int{9} return file_rove_rove_proto_rawDescGZIP(), []int{9}
} }
func (x *Log) GetTime() int64 { func (x *Log) GetTime() string {
if x != nil { if x != nil {
return x.Time return x.Time
} }
return 0 return ""
} }
func (x *Log) GetText() string { func (x *Log) GetText() string {
@ -974,7 +974,7 @@ var file_rove_rove_proto_rawDesc = []byte{
0x74, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x74, 0x12, 0x27, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x6f, 0x76, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e,
0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, 0x03, 0x4c, 0x6f, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2d, 0x0a, 0x03, 0x4c, 0x6f,
0x67, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20,
0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0xb7, 0x03, 0x0a, 0x0e, 0x53, 0x74, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0xb7, 0x03, 0x0a, 0x0e, 0x53, 0x74,
0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04,

View file

@ -256,7 +256,6 @@
"properties": { "properties": {
"time": { "time": {
"type": "string", "type": "string",
"format": "int64",
"title": "The unix timestamp of the log" "title": "The unix timestamp of the log"
}, },
"text": { "text": {

View file

@ -122,7 +122,7 @@ message StatusRequest {
message Log { message Log {
// The unix timestamp of the log // The unix timestamp of the log
int64 time = 1; string time = 1;
// The text of the log // The text of the log
string text = 2; string text = 2;