Skip to content

Commit

Permalink
refactor: rename PrecisionType to Precision (openGemini#69)
Browse files Browse the repository at this point in the history
Signed-off-by: ZhangJian He <shoothzj@gmail.com>
  • Loading branch information
hezhangjian authored Apr 8, 2024
1 parent 46c3d8b commit 2f87c43
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions opengemini/point.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ import (
)

const (
PrecisionNanoSecond PrecisionType = iota
PrecisionNanoSecond Precision = iota
PrecisionMicrosecond
PrecisionMillisecond
PrecisionSecond
PrecisionMinute
PrecisionHour
)

type PrecisionType int
type Precision int

func (p PrecisionType) String() string {
func (p Precision) String() string {
switch p {
case PrecisionNanoSecond:
return "PrecisionNanoSecond"
Expand All @@ -39,7 +39,7 @@ func (p PrecisionType) String() string {
type Point struct {
Measurement string
// Precision Timestamp precision ,default value is PrecisionNanoSecond
Precision PrecisionType
Precision Precision
Time time.Time
Tags map[string]string
Fields map[string]interface{}
Expand All @@ -63,7 +63,7 @@ func (p *Point) SetTime(t time.Time) {
p.Time = t
}

func (p *Point) SetPrecision(precision PrecisionType) {
func (p *Point) SetPrecision(precision Precision) {
p.Precision = precision
}

Expand Down Expand Up @@ -255,7 +255,7 @@ func (enc *LineProtocolEncoder) BatchEncode(bp *BatchPoints) error {
return nil
}

func formatTimestamp(t time.Time, p PrecisionType) string {
func formatTimestamp(t time.Time, p Precision) string {
switch p {
case PrecisionNanoSecond:
return strconv.FormatInt(t.UnixNano(), 10)
Expand Down
2 changes: 1 addition & 1 deletion opengemini/point_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestPointEncode(t *testing.T) {
func TestFormatTimestamp(t *testing.T) {
testTime := time.Date(2023, 12, 1, 12, 32, 18, 132363612, time.UTC)
tests := []struct {
precision PrecisionType
precision Precision
timestamp string
}{
{
Expand Down

0 comments on commit 2f87c43

Please sign in to comment.