From 30ca488890d75802e10336f61b7a811e38473b16 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Thu, 9 Jul 2020 19:38:23 +0100 Subject: [PATCH] Use string for the timestamp, proto uses this under the hood anyway https://github.com/grpc-ecosystem/grpc-gateway/issues/438 --- cmd/rove-server/internal/routes.go | 2 +- pkg/rove/rove.pb.go | 8 ++++---- pkg/rove/rove.swagger.json | 1 - proto/rove/rove.proto | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cmd/rove-server/internal/routes.go b/cmd/rove-server/internal/routes.go index 1079a9d..5236a52 100644 --- a/cmd/rove-server/internal/routes.go +++ b/cmd/rove-server/internal/routes.go @@ -94,7 +94,7 @@ func (s *Server) Status(ctx context.Context, req *rove.StatusRequest) (response for _, log := range rover.Logs { logs = append(logs, &rove.Log{ Text: log.Text, - Time: log.Time.Unix(), + Time: fmt.Sprintf("%d", log.Time.Unix()), // proto uses strings under the hood for 64bit ints anyway }) } diff --git a/pkg/rove/rove.pb.go b/pkg/rove/rove.pb.go index eeaeba6..e38875d 100644 --- a/pkg/rove/rove.pb.go +++ b/pkg/rove/rove.pb.go @@ -504,7 +504,7 @@ type Log struct { unknownFields protoimpl.UnknownFields // 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 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} } -func (x *Log) GetTime() int64 { +func (x *Log) GetTime() string { if x != nil { return x.Time } - return 0 + return "" } 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, 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, - 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, 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, diff --git a/pkg/rove/rove.swagger.json b/pkg/rove/rove.swagger.json index a28fee0..5575c89 100644 --- a/pkg/rove/rove.swagger.json +++ b/pkg/rove/rove.swagger.json @@ -256,7 +256,6 @@ "properties": { "time": { "type": "string", - "format": "int64", "title": "The unix timestamp of the log" }, "text": { diff --git a/proto/rove/rove.proto b/proto/rove/rove.proto index c49e2d8..70b766c 100644 --- a/proto/rove/rove.proto +++ b/proto/rove/rove.proto @@ -122,7 +122,7 @@ message StatusRequest { message Log { // The unix timestamp of the log - int64 time = 1; + string time = 1; // The text of the log string text = 2;