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

all: using the more elegant way to deal milliseconds and nanoseconds #292

Merged
merged 1 commit into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ func logf(c *context, level int64, format string, args ...interface{}) {
s = strings.TrimRight(s, "\n") // Remove any trailing newline characters.
if logToLogservice() {
c.addLogLine(&logpb.UserAppLogLine{
TimestampUsec: proto.Int64(time.Now().UnixNano() / 1e3),
TimestampUsec: proto.Int64(time.Now().UnixMicro()),
Level: &level,
Message: &s,
})
Expand Down
4 changes: 2 additions & 2 deletions log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,10 @@ func makeRequest(params *Query, appID, versionID string) (*pb.LogReadRequest, er
req := &pb.LogReadRequest{}
req.AppId = &appID
if !params.StartTime.IsZero() {
req.StartTime = proto.Int64(params.StartTime.UnixNano() / 1e3)
req.StartTime = proto.Int64(params.StartTime.UnixMicro())
}
if !params.EndTime.IsZero() {
req.EndTime = proto.Int64(params.EndTime.UnixNano() / 1e3)
req.EndTime = proto.Int64(params.EndTime.UnixMicro())
}
if len(params.Offset) > 0 {
var offset pb.LogOffset
Expand Down
2 changes: 1 addition & 1 deletion search/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ func fieldsToProto(src []Field) ([]*pb.Field, error) {
}
timeFields[f.Name] = true
fieldValue.Type = pb.FieldValue_DATE.Enum()
fieldValue.StringValue = proto.String(strconv.FormatInt(x.UnixNano()/1e6, 10))
fieldValue.StringValue = proto.String(strconv.FormatInt(x.UnixMilli(), 10))
case float64:
if numericFields[f.Name] {
return nil, fmt.Errorf("search: duplicate numeric field %q", f.Name)
Expand Down
4 changes: 2 additions & 2 deletions taskqueue/taskqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func newAddReq(c context.Context, task *Task, queueName string) (*pb.TaskQueueAd
req := &pb.TaskQueueAddRequest{
QueueName: []byte(queueName),
TaskName: []byte(task.Name),
EtaUsec: proto.Int64(eta.UnixNano() / 1e3),
EtaUsec: proto.Int64(eta.UnixMicro()),
}
method := task.method()
if method == "PULL" {
Expand Down Expand Up @@ -467,7 +467,7 @@ func ModifyLease(c context.Context, task *Task, queueName string, leaseTime int)
req := &pb.TaskQueueModifyTaskLeaseRequest{
QueueName: []byte(queueName),
TaskName: []byte(task.Name),
EtaUsec: proto.Int64(task.ETA.UnixNano() / 1e3), // Used to verify ownership.
EtaUsec: proto.Int64(task.ETA.UnixMicro()), // Used to verify ownership.
LeaseSeconds: proto.Float64(float64(leaseTime)),
}
res := &pb.TaskQueueModifyTaskLeaseResponse{}
Expand Down
4 changes: 2 additions & 2 deletions v2/taskqueue/taskqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func newAddReq(c context.Context, task *Task, queueName string) (*pb.TaskQueueAd
req := &pb.TaskQueueAddRequest{
QueueName: []byte(queueName),
TaskName: []byte(task.Name),
EtaUsec: proto.Int64(eta.UnixNano() / 1e3),
EtaUsec: proto.Int64(eta.UnixMicro()),
}
method := task.method()
if method == "PULL" {
Expand Down Expand Up @@ -467,7 +467,7 @@ func ModifyLease(c context.Context, task *Task, queueName string, leaseTime int)
req := &pb.TaskQueueModifyTaskLeaseRequest{
QueueName: []byte(queueName),
TaskName: []byte(task.Name),
EtaUsec: proto.Int64(task.ETA.UnixNano() / 1e3), // Used to verify ownership.
EtaUsec: proto.Int64(task.ETA.UnixMicro()), // Used to verify ownership.
LeaseSeconds: proto.Float64(float64(leaseTime)),
}
res := &pb.TaskQueueModifyTaskLeaseResponse{}
Expand Down