From 12543ec0fd07f60becabc7169543ce7510c492b9 Mon Sep 17 00:00:00 2001 From: Hangjie Mo Date: Thu, 13 Jul 2023 16:56:14 +0800 Subject: [PATCH] *: remove TSOToRoughTime function (#45348) --- executor/show.go | 3 ++- tidb-binlog/node/BUILD.bazel | 2 +- tidb-binlog/node/node.go | 4 ++-- util/BUILD.bazel | 1 - util/tso.go | 25 ------------------------- 5 files changed, 5 insertions(+), 30 deletions(-) delete mode 100644 util/tso.go diff --git a/executor/show.go b/executor/show.go index b1293aed14ab6..5f22d8271c7cb 100644 --- a/executor/show.go +++ b/executor/show.go @@ -79,6 +79,7 @@ import ( "github.com/pingcap/tidb/util/set" "github.com/pingcap/tidb/util/sqlexec" "github.com/pingcap/tidb/util/stringutil" + "github.com/tikv/client-go/v2/oracle" "golang.org/x/exp/slices" ) @@ -1898,7 +1899,7 @@ func (e *ShowExec) fetchShowPumpOrDrainerStatus(kind string) error { if n.State == node.Offline { continue } - e.appendRow([]interface{}{n.NodeID, n.Addr, n.State, n.MaxCommitTS, util.TSOToRoughTime(n.UpdateTS).Format(types.TimeFormat)}) + e.appendRow([]interface{}{n.NodeID, n.Addr, n.State, n.MaxCommitTS, oracle.GetTimeFromTS(uint64(n.UpdateTS)).Format(types.TimeFormat)}) } return nil diff --git a/tidb-binlog/node/BUILD.bazel b/tidb-binlog/node/BUILD.bazel index 31853fec390c1..8c5116e05327d 100644 --- a/tidb-binlog/node/BUILD.bazel +++ b/tidb-binlog/node/BUILD.bazel @@ -9,10 +9,10 @@ go_library( importpath = "github.com/pingcap/tidb/tidb-binlog/node", visibility = ["//visibility:public"], deps = [ - "//util", "//util/etcd", "@com_github_pingcap_errors//:errors", "@com_github_pingcap_log//:log", + "@com_github_tikv_client_go_v2//oracle", "@io_etcd_go_etcd_client_v3//:client", "@org_uber_go_zap//:zap", ], diff --git a/tidb-binlog/node/node.go b/tidb-binlog/node/node.go index 5f54645fab296..f6206f7f55e25 100644 --- a/tidb-binlog/node/node.go +++ b/tidb-binlog/node/node.go @@ -17,7 +17,7 @@ package node import ( "fmt" - "github.com/pingcap/tidb/util" + "github.com/tikv/client-go/v2/oracle" ) var ( @@ -90,6 +90,6 @@ type Status struct { } func (s *Status) String() string { - updateTime := util.TSOToRoughTime(s.UpdateTS) + updateTime := oracle.GetTimeFromTS(uint64(s.UpdateTS)) return fmt.Sprintf("{NodeID: %s, Addr: %s, State: %s, MaxCommitTS: %d, UpdateTime: %v}", s.NodeID, s.Addr, s.State, s.MaxCommitTS, updateTime) } diff --git a/util/BUILD.bazel b/util/BUILD.bazel index f8fcd64a03e88..532ff12d6d805 100644 --- a/util/BUILD.bazel +++ b/util/BUILD.bazel @@ -16,7 +16,6 @@ go_library( "rlimit_other.go", "rlimit_windows.go", "security.go", - "tso.go", "urls.go", "util.go", "wait_group_wrapper.go", diff --git a/util/tso.go b/util/tso.go deleted file mode 100644 index 0a2a0dec9ac18..0000000000000 --- a/util/tso.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2022 PingCAP, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package util - -import ( - "time" -) - -// TSOToRoughTime translates tso to rough time that used to display -func TSOToRoughTime(ts int64) time.Time { - t := time.Unix(ts>>18/1000, 0) - return t -}