From ff8f87bfe1451e0c512ceb8fdbcbf87773639331 Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Tue, 16 Aug 2022 22:30:57 +0800 Subject: [PATCH 01/45] add snowflake sequencer --- cmd/layotto/main.go | 4 + components/go.mod | 2 + components/go.sum | 4 + components/pkg/utils/snowflake/ringbuffer.go | 174 +++++++++++ components/pkg/utils/snowflake/snowflake.go | 290 ++++++++++++++++++ .../snowflake/snowflake_sequencer.go | 103 +++++++ .../snowflake/snowflake_sequencer_test.go | 98 ++++++ go.sum | 5 +- 8 files changed, 679 insertions(+), 1 deletion(-) create mode 100755 components/pkg/utils/snowflake/ringbuffer.go create mode 100755 components/pkg/utils/snowflake/snowflake.go create mode 100755 components/sequencer/snowflake/snowflake_sequencer.go create mode 100755 components/sequencer/snowflake/snowflake_sequencer_test.go diff --git a/cmd/layotto/main.go b/cmd/layotto/main.go index cf320b3cd1..00c60b316f 100644 --- a/cmd/layotto/main.go +++ b/cmd/layotto/main.go @@ -133,6 +133,7 @@ import ( sequencer_mongo "mosn.io/layotto/components/sequencer/mongo" sequencer_mysql "mosn.io/layotto/components/sequencer/mysql" sequencer_redis "mosn.io/layotto/components/sequencer/redis" + sequencer_snowflake "mosn.io/layotto/components/sequencer/snowflake" sequencer_zookeeper "mosn.io/layotto/components/sequencer/zookeeper" // Actuator @@ -440,6 +441,9 @@ func NewRuntimeGrpcServer(data json.RawMessage, opts ...grpc.ServerOption) (mgrp runtime_sequencer.NewFactory("mysql", func() sequencer.Store { return sequencer_mysql.NewMySQLSequencer(log.DefaultLogger) }), + runtime_sequencer.NewFactory("snowflake", func() sequencer.Store { + return sequencer_snowflake.NewSnowFlakeSequencer(log.DefaultLogger) + }), ), // secretstores runtime.WithSecretStoresFactory( diff --git a/components/go.mod b/components/go.mod index 8c21771414..9138c2d4a4 100644 --- a/components/go.mod +++ b/components/go.mod @@ -14,7 +14,9 @@ require ( github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.14 github.com/aws/aws-sdk-go-v2/service/s3 v1.26.10 github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f // indirect + github.com/deckarep/golang-set v1.8.0 github.com/go-redis/redis/v8 v8.8.0 + github.com/go-sql-driver/mysql v1.6.0 github.com/go-zookeeper/zk v1.0.2 github.com/golang/mock v1.6.0 github.com/google/uuid v1.3.0 diff --git a/components/go.sum b/components/go.sum index 15f5abde5f..14b1df4ac6 100644 --- a/components/go.sum +++ b/components/go.sum @@ -204,6 +204,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= +github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= +github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= github.com/denisenkom/go-mssqldb v0.0.0-20190707035753-2be1aa521ff4/go.mod h1:zAg7JM8CkOJ43xKXIj7eRO9kmWm/TW578qo+oDO6tuM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= @@ -290,6 +292,8 @@ github.com/go-resty/resty/v2 v2.6.0/go.mod h1:PwvJS6hvaPkjtjNg9ph+VrSD92bi5Zq73w github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= +github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:56xuuqnHyryaerycW3BfssRdxQstACi0Epw/yC5E2xM= diff --git a/components/pkg/utils/snowflake/ringbuffer.go b/components/pkg/utils/snowflake/ringbuffer.go new file mode 100755 index 0000000000..b048068165 --- /dev/null +++ b/components/pkg/utils/snowflake/ringbuffer.go @@ -0,0 +1,174 @@ +// +// Copyright 2021 Layotto Authors +// 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 snowflake + +import ( + "errors" + "runtime" + "sync" + "sync/atomic" + + "mosn.io/pkg/log" +) + +const ( + CAN_TAKE_FLAG = 1 + CAN_PUT_FLAG = 0 +) + +//avoid false sharing +type PaddedInt struct { + _ [7]int64 + Value int64 + _ [7]int64 +} + +type RingBuffer struct { + m sync.Mutex + slots []int64 + flags []PaddedInt + tail PaddedInt + cursor PaddedInt + bufferSize int64 + + PaddingFactor int64 + CurrentTimeStamp int64 + WorkId int64 + + TimeBits int64 + WorkIdBits int64 + SeqBits int64 + + MaxSeq int64 + GoNum int32 +} + +var cores int = runtime.NumCPU() + +func NewRingBuffer(bufferSize int64) *RingBuffer { + p := PaddedInt{} + p.Value = -1 + return &RingBuffer{ + slots: make([]int64, bufferSize), + flags: make([]PaddedInt, bufferSize), + tail: p, + cursor: p, + bufferSize: bufferSize, + GoNum: 1, + } +} + +func (r *RingBuffer) Put(uid int64) (bool, error) { + r.m.Lock() + defer r.m.Unlock() + currentTail := r.tail.Value + currentCursor := r.cursor.Value + if currentCursor == -1 { + currentCursor = 0 + } + distance := currentTail - currentCursor + if distance == r.bufferSize-1 { + return false, errors.New("Catched!Rejected putting buffer") + } + + //(currentTail + 1) mod r.bufferSize + nextTailIndex := (currentTail + 1) & (r.bufferSize - 1) + + if r.flags[nextTailIndex].Value != CAN_PUT_FLAG { + return false, errors.New("Tail not in can put status") + } + + r.slots[nextTailIndex] = uid + r.flags[nextTailIndex].Value = CAN_TAKE_FLAG + r.tail.Value++ + return true, nil +} + +func (r *RingBuffer) Take() (int64, error) { + r.m.Lock() + defer r.m.Unlock() + var uid int64 + currentCursor := r.cursor.Value + if r.cursor.Value != r.tail.Value { + r.cursor.Value++ + } + nextCursor := r.cursor.Value + currentTail := r.tail.Value + + if currentTail-nextCursor < r.PaddingFactor*r.bufferSize/100 { + //limit the numbers of goroutine + if int(r.GoNum) <= 2*cores { + r.GoNum++ + go r.PaddingRingBuffer() + } + } + + if currentCursor == nextCursor { + return uid, errors.New("Buffer is empty, rejected take buffer.") + } + + //check next slot flag is CAN_TAKE_FLAG + nextCursorIndex := (nextCursor) & (r.bufferSize - 1) + if r.flags[nextCursorIndex].Value != CAN_TAKE_FLAG { + return uid, errors.New("Curosr not in can take status") + } + + uid = r.slots[nextCursorIndex] + r.flags[nextCursorIndex].Value = CAN_PUT_FLAG + return uid, nil +} + +func (r *RingBuffer) Allocator() int64 { + var sequence int64 + timestampShift := r.WorkIdBits + r.SeqBits + workidShift := r.SeqBits + workid := r.WorkId + r.m.Lock() + timestamp := r.CurrentTimeStamp + r.CurrentTimeStamp++ + r.m.Unlock() + return timestamp< Date: Wed, 17 Aug 2022 10:34:54 +0800 Subject: [PATCH 02/45] add snowflake sequencer --- components/pkg/utils/snowflake/ringbuffer.go | 12 +++----- components/pkg/utils/snowflake/snowflake.go | 28 ++++++++----------- .../snowflake/snowflake_sequencer.go | 6 +--- 3 files changed, 17 insertions(+), 29 deletions(-) diff --git a/components/pkg/utils/snowflake/ringbuffer.go b/components/pkg/utils/snowflake/ringbuffer.go index b048068165..8950e26ea1 100755 --- a/components/pkg/utils/snowflake/ringbuffer.go +++ b/components/pkg/utils/snowflake/ringbuffer.go @@ -79,14 +79,14 @@ func (r *RingBuffer) Put(uid int64) (bool, error) { } distance := currentTail - currentCursor if distance == r.bufferSize-1 { - return false, errors.New("Catched!Rejected putting buffer") + return false, errors.New("catched!Rejected putting buffer") } //(currentTail + 1) mod r.bufferSize nextTailIndex := (currentTail + 1) & (r.bufferSize - 1) if r.flags[nextTailIndex].Value != CAN_PUT_FLAG { - return false, errors.New("Tail not in can put status") + return false, errors.New("tail not in can put status") } r.slots[nextTailIndex] = uid @@ -115,13 +115,13 @@ func (r *RingBuffer) Take() (int64, error) { } if currentCursor == nextCursor { - return uid, errors.New("Buffer is empty, rejected take buffer.") + return uid, errors.New("buffer is empty, rejected take buffer") } //check next slot flag is CAN_TAKE_FLAG nextCursorIndex := (nextCursor) & (r.bufferSize - 1) if r.flags[nextCursorIndex].Value != CAN_TAKE_FLAG { - return uid, errors.New("Curosr not in can take status") + return uid, errors.New("curosr not in can take status") } uid = r.slots[nextCursorIndex] @@ -168,7 +168,3 @@ func (r *RingBuffer) PaddingRingBuffer() { } atomic.AddInt32(&r.GoNum, -1) } - -func (r *RingBuffer) needPadding() bool { - return r.tail.Value-r.cursor.Value <= r.bufferSize-r.MaxSeq -} diff --git a/components/pkg/utils/snowflake/snowflake.go b/components/pkg/utils/snowflake/snowflake.go index 26ef1d2954..7dd5534175 100755 --- a/components/pkg/utils/snowflake/snowflake.go +++ b/components/pkg/utils/snowflake/snowflake.go @@ -21,24 +21,21 @@ import ( "net" "strconv" "time" - - _ "github.com/go-sql-driver/mysql" ) const ( - mysqlUrl = "mysql" - databaseName = "databaseName" - tableName = "tableName" - userName = "userName" - password = "password" - charset = "utf8" - boostPower = "boostPower" - paddingFactor = "paddingFactor" - scheduleInterval = "scheduleInterval" - timeBits = "timeBits" - workerBits = "workerBits" - seqBits = "seqBits" - startTime = "startTime" + mysqlUrl = "mysql" + databaseName = "databaseName" + tableName = "tableName" + userName = "userName" + password = "password" + charset = "utf8" + boostPower = "boostPower" + paddingFactor = "paddingFactor" + timeBits = "timeBits" + workerBits = "workerBits" + seqBits = "seqBits" + startTime = "startTime" defalutBoostPower = 3 defalutPaddingFactor = 50 @@ -160,7 +157,6 @@ func NewMysqlClient(meta MysqlMetadata) (int64, error) { } exists, err := tableExists(meta) - if !exists { createTable := fmt.Sprintf( `CREATE TABLE IF NOT EXISTS %s( diff --git a/components/sequencer/snowflake/snowflake_sequencer.go b/components/sequencer/snowflake/snowflake_sequencer.go index 7ad12f93cb..06bd8c8c78 100755 --- a/components/sequencer/snowflake/snowflake_sequencer.go +++ b/components/sequencer/snowflake/snowflake_sequencer.go @@ -14,7 +14,6 @@ package snowflake import ( - "context" "database/sql" "time" @@ -31,8 +30,6 @@ type SnowFlakeSequencer struct { db *sql.DB biggerThan map[string]int64 logger log.ErrorLogger - ctx context.Context - cancel context.CancelFunc } func NewSnowFlakeSequencer(logger log.ErrorLogger) *SnowFlakeSequencer { @@ -65,8 +62,7 @@ func (s *SnowFlakeSequencer) Init(config sequencer.Configuration) error { var maxSeq int64 maxSeq = ^(-1 << seqBits) + 1 - var bufferSize int64 - bufferSize = maxSeq << rm.BoostPower + bufferSize := maxSeq << rm.BoostPower s.ringBuffer = snowflake.NewRingBuffer(bufferSize) From 0bbf50bc98cfed8491f51c244549f60a2d059b65 Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Wed, 17 Aug 2022 10:51:37 +0800 Subject: [PATCH 03/45] add snowflake sequencer --- components/pkg/utils/snowflake/snowflake.go | 11 ++++++----- components/sequencer/snowflake/snowflake_sequencer.go | 3 +-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/components/pkg/utils/snowflake/snowflake.go b/components/pkg/utils/snowflake/snowflake.go index 7dd5534175..d4955d7e58 100755 --- a/components/pkg/utils/snowflake/snowflake.go +++ b/components/pkg/utils/snowflake/snowflake.go @@ -156,7 +156,8 @@ func NewMysqlClient(meta MysqlMetadata) (int64, error) { meta.Db = db } - exists, err := tableExists(meta) + var err error + exists := tableExists(meta) if !exists { createTable := fmt.Sprintf( `CREATE TABLE IF NOT EXISTS %s( @@ -176,13 +177,13 @@ func NewMysqlClient(meta MysqlMetadata) (int64, error) { return workId, err } -func tableExists(meta MysqlMetadata) (bool, error) { +func tableExists(meta MysqlMetadata) bool { var result string - err := meta.Db.QueryRow(fmt.Sprintf(`SELECT TABLE_NAME FROM information_schema.tables WHERE TABLE_NAME = ?`), meta.TableName).Scan(&result) + err := meta.Db.QueryRow("SELECT TABLE_NAME FROM information_schema.tables WHERE TABLE_NAME = ?", meta.TableName).Scan(&result) if err == sql.ErrNoRows { - return false, err + return false } - return true, err + return true } func NewWorkId(meta MysqlMetadata) (int64, error) { diff --git a/components/sequencer/snowflake/snowflake_sequencer.go b/components/sequencer/snowflake/snowflake_sequencer.go index 06bd8c8c78..b6d9d8e241 100755 --- a/components/sequencer/snowflake/snowflake_sequencer.go +++ b/components/sequencer/snowflake/snowflake_sequencer.go @@ -60,8 +60,7 @@ func (s *SnowFlakeSequencer) Init(config sequencer.Configuration) error { startTime := rm.StartTime seqBits := rm.SeqBits - var maxSeq int64 - maxSeq = ^(-1 << seqBits) + 1 + var maxSeq int64 = ^(-1 << seqBits) + 1 bufferSize := maxSeq << rm.BoostPower s.ringBuffer = snowflake.NewRingBuffer(bufferSize) From 7b1c10af3118f775c6e1e689513c84ce979f0964 Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Wed, 17 Aug 2022 11:08:11 +0800 Subject: [PATCH 04/45] add snowflake sequencer --- components/pkg/utils/snowflake/ringbuffer.go | 25 ++++++++++---------- components/pkg/utils/snowflake/snowflake.go | 5 +--- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/components/pkg/utils/snowflake/ringbuffer.go b/components/pkg/utils/snowflake/ringbuffer.go index 8950e26ea1..a301858b9d 100755 --- a/components/pkg/utils/snowflake/ringbuffer.go +++ b/components/pkg/utils/snowflake/ringbuffer.go @@ -35,23 +35,22 @@ type PaddedInt struct { } type RingBuffer struct { - m sync.Mutex - slots []int64 - flags []PaddedInt - tail PaddedInt - cursor PaddedInt - bufferSize int64 - - PaddingFactor int64 - CurrentTimeStamp int64 - WorkId int64 - + m sync.Mutex + slots []int64 + flags []PaddedInt + tail PaddedInt + cursor PaddedInt + + MaxSeq int64 + GoNum int32 TimeBits int64 WorkIdBits int64 SeqBits int64 + bufferSize int64 + WorkId int64 - MaxSeq int64 - GoNum int32 + PaddingFactor int64 + CurrentTimeStamp int64 } var cores int = runtime.NumCPU() diff --git a/components/pkg/utils/snowflake/snowflake.go b/components/pkg/utils/snowflake/snowflake.go index d4955d7e58..8602938b8e 100755 --- a/components/pkg/utils/snowflake/snowflake.go +++ b/components/pkg/utils/snowflake/snowflake.go @@ -180,10 +180,7 @@ func NewMysqlClient(meta MysqlMetadata) (int64, error) { func tableExists(meta MysqlMetadata) bool { var result string err := meta.Db.QueryRow("SELECT TABLE_NAME FROM information_schema.tables WHERE TABLE_NAME = ?", meta.TableName).Scan(&result) - if err == sql.ErrNoRows { - return false - } - return true + return err != sql.ErrNoRows } func NewWorkId(meta MysqlMetadata) (int64, error) { From a60983075cb312f33e19ab41cd304110828f140f Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Sat, 20 Aug 2022 22:21:02 +0800 Subject: [PATCH 05/45] add snowflake sequencer api --- components/pkg/utils/snowflake/ringbuffer.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/pkg/utils/snowflake/ringbuffer.go b/components/pkg/utils/snowflake/ringbuffer.go index a301858b9d..5618848279 100755 --- a/components/pkg/utils/snowflake/ringbuffer.go +++ b/components/pkg/utils/snowflake/ringbuffer.go @@ -130,8 +130,8 @@ func (r *RingBuffer) Take() (int64, error) { func (r *RingBuffer) Allocator() int64 { var sequence int64 - timestampShift := r.WorkIdBits + r.SeqBits - workidShift := r.SeqBits + timestampShift := r.SeqBits + workidShift := r.TimeBits + r.SeqBits workid := r.WorkId r.m.Lock() timestamp := r.CurrentTimeStamp From 5b41905c8c89e54508dbf8166653ece7d03ae436 Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Sun, 21 Aug 2022 18:27:48 +0800 Subject: [PATCH 06/45] add snowflake sequencer api --- components/pkg/utils/snowflake/ringbuffer.go | 1 - 1 file changed, 1 deletion(-) diff --git a/components/pkg/utils/snowflake/ringbuffer.go b/components/pkg/utils/snowflake/ringbuffer.go index 5618848279..a3fe04971c 100755 --- a/components/pkg/utils/snowflake/ringbuffer.go +++ b/components/pkg/utils/snowflake/ringbuffer.go @@ -31,7 +31,6 @@ const ( type PaddedInt struct { _ [7]int64 Value int64 - _ [7]int64 } type RingBuffer struct { From a1e5ac166b878428e180af3a8517d3ec14c5e2d9 Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Fri, 2 Sep 2022 22:48:25 +0800 Subject: [PATCH 07/45] add comments --- components/pkg/utils/snowflake/ringbuffer.go | 102 ++++++++++-------- components/pkg/utils/snowflake/snowflake.go | 42 +++++--- .../pkg/utils/snowflake/snowflake_test.go | 38 +++++++ .../snowflake/snowflake_sequencer.go | 13 +-- .../snowflake/snowflake_sequencer_test.go | 5 +- 5 files changed, 133 insertions(+), 67 deletions(-) create mode 100644 components/pkg/utils/snowflake/snowflake_test.go diff --git a/components/pkg/utils/snowflake/ringbuffer.go b/components/pkg/utils/snowflake/ringbuffer.go index a3fe04971c..1b307712eb 100755 --- a/components/pkg/utils/snowflake/ringbuffer.go +++ b/components/pkg/utils/snowflake/ringbuffer.go @@ -33,23 +33,35 @@ type PaddedInt struct { Value int64 } +//there are two ringbuffers, one is to store uid, another is to store flag, flag represents the slot is readable or writable type RingBuffer struct { - m sync.Mutex - slots []int64 - flags []PaddedInt - tail PaddedInt - cursor PaddedInt - - MaxSeq int64 - GoNum int32 + m sync.Mutex + //store uid + slots []int64 + //store flag + flags []PaddedInt + //write pointer, wp is readable, next is writable + wp PaddedInt + //read pointer, rp is writable, next is readable + rp PaddedInt + + //uid = 0 + WorkIdBits + TimeBits + SeqBits TimeBits int64 WorkIdBits int64 SeqBits int64 + + //ringbuffer's size bufferSize int64 - WorkId int64 + //when readable slots nums <= bufferSize * PaddingFactor / 100, start a new goroutine + PaddingFactor int64 - PaddingFactor int64 + //get id from Mysql at startup + WorkId int64 + //get current timestamp at startup CurrentTimeStamp int64 + + //asynchronously running padding goroutine numbers + GoNum int32 } var cores int = runtime.NumCPU() @@ -60,8 +72,8 @@ func NewRingBuffer(bufferSize int64) *RingBuffer { return &RingBuffer{ slots: make([]int64, bufferSize), flags: make([]PaddedInt, bufferSize), - tail: p, - cursor: p, + wp: p, + rp: p, bufferSize: bufferSize, GoNum: 1, } @@ -70,26 +82,27 @@ func NewRingBuffer(bufferSize int64) *RingBuffer { func (r *RingBuffer) Put(uid int64) (bool, error) { r.m.Lock() defer r.m.Unlock() - currentTail := r.tail.Value - currentCursor := r.cursor.Value - if currentCursor == -1 { - currentCursor = 0 + currentWritePointer := r.wp.Value + currentReadPointer := r.rp.Value + if currentReadPointer == -1 { + currentReadPointer = 0 } - distance := currentTail - currentCursor + distance := currentWritePointer - currentReadPointer + //write pointer catches read pointer, ringbuffer is full if distance == r.bufferSize-1 { - return false, errors.New("catched!Rejected putting buffer") + return false, errors.New("ringbuffer is full! Rejected putting buffer") } - //(currentTail + 1) mod r.bufferSize - nextTailIndex := (currentTail + 1) & (r.bufferSize - 1) + //(currentWritePointer + 1) mod r.bufferSize + nextWriteIndex := (currentWritePointer + 1) & (r.bufferSize - 1) - if r.flags[nextTailIndex].Value != CAN_PUT_FLAG { - return false, errors.New("tail not in can put status") + if r.flags[nextWriteIndex].Value != CAN_PUT_FLAG { + return false, errors.New("slot is not in writable status") } - r.slots[nextTailIndex] = uid - r.flags[nextTailIndex].Value = CAN_TAKE_FLAG - r.tail.Value++ + r.slots[nextWriteIndex] = uid + r.flags[nextWriteIndex].Value = CAN_TAKE_FLAG + r.wp.Value++ return true, nil } @@ -97,14 +110,14 @@ func (r *RingBuffer) Take() (int64, error) { r.m.Lock() defer r.m.Unlock() var uid int64 - currentCursor := r.cursor.Value - if r.cursor.Value != r.tail.Value { - r.cursor.Value++ + + if r.rp.Value != r.wp.Value { + r.rp.Value++ + } else { + return uid, errors.New("buffer is empty, rejected take buffer") } - nextCursor := r.cursor.Value - currentTail := r.tail.Value - if currentTail-nextCursor < r.PaddingFactor*r.bufferSize/100 { + if r.wp.Value-r.rp.Value < r.bufferSize*r.PaddingFactor/100 { //limit the numbers of goroutine if int(r.GoNum) <= 2*cores { r.GoNum++ @@ -112,35 +125,39 @@ func (r *RingBuffer) Take() (int64, error) { } } - if currentCursor == nextCursor { - return uid, errors.New("buffer is empty, rejected take buffer") - } - //check next slot flag is CAN_TAKE_FLAG - nextCursorIndex := (nextCursor) & (r.bufferSize - 1) - if r.flags[nextCursorIndex].Value != CAN_TAKE_FLAG { - return uid, errors.New("curosr not in can take status") + nextReadIndex := (r.rp.Value) & (r.bufferSize - 1) + if r.flags[nextReadIndex].Value != CAN_TAKE_FLAG { + return uid, errors.New("slot not in readable status") } - uid = r.slots[nextCursorIndex] - r.flags[nextCursorIndex].Value = CAN_PUT_FLAG + uid = r.slots[nextReadIndex] + r.flags[nextReadIndex].Value = CAN_PUT_FLAG return uid, nil } +//allocate bits for uid +//workid + time + sequence func (r *RingBuffer) Allocator() int64 { var sequence int64 + timestampShift := r.SeqBits workidShift := r.TimeBits + r.SeqBits + workid := r.WorkId + r.m.Lock() timestamp := r.CurrentTimeStamp r.CurrentTimeStamp++ r.m.Unlock() + return timestamp< Date: Mon, 5 Sep 2022 18:59:16 +0800 Subject: [PATCH 08/45] add UT --- .../snowflake/snowflake_sequencer_test.go | 70 +++++++++++++++++-- 1 file changed, 66 insertions(+), 4 deletions(-) diff --git a/components/sequencer/snowflake/snowflake_sequencer_test.go b/components/sequencer/snowflake/snowflake_sequencer_test.go index 65da7e4a96..1803f8d499 100755 --- a/components/sequencer/snowflake/snowflake_sequencer_test.go +++ b/components/sequencer/snowflake/snowflake_sequencer_test.go @@ -15,7 +15,8 @@ package snowflake import ( "database/sql" - "fmt" + "runtime" + "sync" "testing" "github.com/DATA-DOG/go-sqlmock" @@ -87,15 +88,76 @@ func TestSnowFlakeSequence_GetNextId(t *testing.T) { mset := mapset.NewSet() - var size int = 1000 + var size int = 10000 for i := 0; i < size; i++ { resp, err := s.GetNextId(&sequencer.GetNextIdRequest{ Key: key, }) - - fmt.Printf("%b \n", resp.NextId) assert.NoError(t, err) mset.Add(resp.NextId) } assert.Equal(t, size, mset.Cardinality()) } + +func TestSnowFlakeSequence_ParallelGetNextId(t *testing.T) { + db, mock, err := sqlmock.New() + if err != nil { + t.Fatalf("an error '%s' was not expected when opening a stub database connection", err) + } + + s := NewSnowFlakeSequencer(log.DefaultLogger) + s.db = db + + mock.ExpectQuery("SELECT TABLE_NAME").WillReturnError(sql.ErrNoRows) + mock.ExpectExec("CREATE TABLE").WillReturnResult(sqlmock.NewResult(1, 1)) + mock.ExpectBegin() + mock.ExpectQuery("SELECT HOST_NAME").WillReturnError(sql.ErrNoRows) + mock.ExpectExec("INSERT INTO").WillReturnResult(sqlmock.NewResult(1, 1)) + mock.ExpectQuery("SELECT ID").WillReturnRows(sqlmock.NewRows([]string{"id"}).AddRow(1)) + mock.ExpectCommit() + + cfg := sequencer.Configuration{ + Properties: make(map[string]string), + BiggerThan: make(map[string]int64), + } + + cfg.Properties["mysql"] = mysqlUrl + cfg.Properties["databaseName"] = databaseName + cfg.Properties["tableName"] = tableName + cfg.Properties["userName"] = userName + cfg.Properties["password"] = password + + cfg.Properties["boostPower"] = boostPower + cfg.Properties["paddingFactor"] = paddingFactor + cfg.Properties["timeBits"] = timeBits + cfg.Properties["workerBits"] = workerBits + cfg.Properties["seqBits"] = seqBits + cfg.Properties["startTime"] = startTime + + err = s.Init(cfg) + + assert.NoError(t, err) + + mset := mapset.NewSet() + + var size int = 10000 + var cores int = runtime.NumCPU() + + var wg sync.WaitGroup + wg.Add(cores) + + for i := 0; i < cores; i++ { + go func() { + for j := 0; j < size; j++ { + resp, err := s.GetNextId(&sequencer.GetNextIdRequest{ + Key: key, + }) + assert.NoError(t, err) + mset.Add(resp.NextId) + } + wg.Done() + }() + } + wg.Wait() + assert.Equal(t, size * cores, mset.Cardinality()) +} From e058a4db8aa287073b1726aa48e66e9668523660 Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Wed, 7 Sep 2022 09:04:29 +0800 Subject: [PATCH 09/45] add snowflake sequencer api --- components/sequencer/snowflake/snowflake_sequencer_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/sequencer/snowflake/snowflake_sequencer_test.go b/components/sequencer/snowflake/snowflake_sequencer_test.go index 1803f8d499..a8d4bdff8c 100755 --- a/components/sequencer/snowflake/snowflake_sequencer_test.go +++ b/components/sequencer/snowflake/snowflake_sequencer_test.go @@ -140,7 +140,7 @@ func TestSnowFlakeSequence_ParallelGetNextId(t *testing.T) { mset := mapset.NewSet() - var size int = 10000 + var size int = 1000 var cores int = runtime.NumCPU() var wg sync.WaitGroup @@ -159,5 +159,5 @@ func TestSnowFlakeSequence_ParallelGetNextId(t *testing.T) { }() } wg.Wait() - assert.Equal(t, size * cores, mset.Cardinality()) + assert.Equal(t, size*cores, mset.Cardinality()) } From 47e9100e9e5b8ab72d4662335ffe1d639641ca84 Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Wed, 7 Sep 2022 09:15:42 +0800 Subject: [PATCH 10/45] add snowflake sequencer api --- sdk/go-sdk/client/client.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/go-sdk/client/client.go b/sdk/go-sdk/client/client.go index decfb69c25..12a41a8f07 100644 --- a/sdk/go-sdk/client/client.go +++ b/sdk/go-sdk/client/client.go @@ -19,11 +19,12 @@ package client import ( "context" "log" - "mosn.io/layotto/spec/proto/extension/v1/s3" "net" "os" "sync" + "mosn.io/layotto/spec/proto/extension/v1/s3" + "github.com/pkg/errors" "google.golang.org/grpc" From c82fe3fc569bfab428f1fd18d97588c8ca4e01d3 Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Wed, 7 Sep 2022 15:19:16 +0800 Subject: [PATCH 11/45] add snowflake sequencer api --- components/pkg/utils/snowflake/snowflake_test.go | 10 +++++++++- .../sequencer/snowflake/snowflake_sequencer_test.go | 12 +++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/components/pkg/utils/snowflake/snowflake_test.go b/components/pkg/utils/snowflake/snowflake_test.go index 4891957a12..c50b307293 100644 --- a/components/pkg/utils/snowflake/snowflake_test.go +++ b/components/pkg/utils/snowflake/snowflake_test.go @@ -19,7 +19,7 @@ import ( "github.com/stretchr/testify/assert" ) -func TestParseSnowflakeRingBufferMetadata(t *testing.T) { +func TestParseSnowflakeRingBufferMetadataBitsSum(t *testing.T) { properties := make(map[string]string) properties["workerBits"] = "1" properties["timeBits"] = "1" @@ -29,6 +29,14 @@ func TestParseSnowflakeRingBufferMetadata(t *testing.T) { assert.Error(t, err) } +func TestParseSnowflakeRingBufferMetadataTimeFormat(t *testing.T) { + properties := make(map[string]string) + properties["startTime"] = "2022.01.01" + + _, err := ParseSnowflakeRingBufferMetadata(properties) + assert.Error(t, err) +} + func TestParseSnowflakeMysqlMetadata(t *testing.T) { properties := make(map[string]string) properties["tableName"] = "layotto_sequence_snowflake" diff --git a/components/sequencer/snowflake/snowflake_sequencer_test.go b/components/sequencer/snowflake/snowflake_sequencer_test.go index a8d4bdff8c..ac2f761494 100755 --- a/components/sequencer/snowflake/snowflake_sequencer_test.go +++ b/components/sequencer/snowflake/snowflake_sequencer_test.go @@ -127,13 +127,6 @@ func TestSnowFlakeSequence_ParallelGetNextId(t *testing.T) { cfg.Properties["userName"] = userName cfg.Properties["password"] = password - cfg.Properties["boostPower"] = boostPower - cfg.Properties["paddingFactor"] = paddingFactor - cfg.Properties["timeBits"] = timeBits - cfg.Properties["workerBits"] = workerBits - cfg.Properties["seqBits"] = seqBits - cfg.Properties["startTime"] = startTime - err = s.Init(cfg) assert.NoError(t, err) @@ -148,6 +141,11 @@ func TestSnowFlakeSequence_ParallelGetNextId(t *testing.T) { for i := 0; i < cores; i++ { go func() { + defer func() { + if x := recover(); x != nil { + log.DefaultLogger.Errorf("panic when testing parallel generatoring uid with snowflake algorithm: %v", x) + } + }() for j := 0; j < size; j++ { resp, err := s.GetNextId(&sequencer.GetNextIdRequest{ Key: key, From df7ec3f6ba5db5fda98eeb329a49ef0e30c73c77 Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Wed, 7 Sep 2022 16:16:20 +0800 Subject: [PATCH 12/45] add snowflake sequencer api --- components/pkg/utils/snowflake/snowflake_test.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/components/pkg/utils/snowflake/snowflake_test.go b/components/pkg/utils/snowflake/snowflake_test.go index c50b307293..d4d41bee79 100644 --- a/components/pkg/utils/snowflake/snowflake_test.go +++ b/components/pkg/utils/snowflake/snowflake_test.go @@ -19,21 +19,17 @@ import ( "github.com/stretchr/testify/assert" ) -func TestParseSnowflakeRingBufferMetadataBitsSum(t *testing.T) { +func TestParseSnowflakeRingBufferMetadata(t *testing.T) { properties := make(map[string]string) + properties["workerBits"] = "1" properties["timeBits"] = "1" properties["seqBits"] = "1" - _, err := ParseSnowflakeRingBufferMetadata(properties) assert.Error(t, err) -} -func TestParseSnowflakeRingBufferMetadataTimeFormat(t *testing.T) { - properties := make(map[string]string) properties["startTime"] = "2022.01.01" - - _, err := ParseSnowflakeRingBufferMetadata(properties) + _, err = ParseSnowflakeRingBufferMetadata(properties) assert.Error(t, err) } From 7b0b0a993cca8090d49f8380f999bc8441951411 Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Tue, 20 Sep 2022 22:12:37 +0800 Subject: [PATCH 13/45] fix some bugs --- components/pkg/utils/snowflake/ringbuffer.go | 89 +++++++++++-------- components/pkg/utils/snowflake/snowflake.go | 33 +++---- .../snowflake/snowflake_sequencer.go | 3 +- .../snowflake/snowflake_sequencer_test.go | 19 +++- sdk/go-sdk/client/client.go | 2 - 5 files changed, 86 insertions(+), 60 deletions(-) diff --git a/components/pkg/utils/snowflake/ringbuffer.go b/components/pkg/utils/snowflake/ringbuffer.go index 1b307712eb..72baa31757 100755 --- a/components/pkg/utils/snowflake/ringbuffer.go +++ b/components/pkg/utils/snowflake/ringbuffer.go @@ -15,9 +15,9 @@ package snowflake import ( "errors" - "runtime" "sync" "sync/atomic" + "time" "mosn.io/pkg/log" ) @@ -45,14 +45,14 @@ type RingBuffer struct { //read pointer, rp is writable, next is readable rp PaddedInt - //uid = 0 + WorkIdBits + TimeBits + SeqBits + //1 + WorkIdBits + TimeBits + SeqBits = 64 TimeBits int64 WorkIdBits int64 SeqBits int64 //ringbuffer's size bufferSize int64 - //when readable slots nums <= bufferSize * PaddingFactor / 100, start a new goroutine + //when readable slots nums <= bufferSize * PaddingFactor / 100, start padding goroutine PaddingFactor int64 //get id from Mysql at startup @@ -60,12 +60,10 @@ type RingBuffer struct { //get current timestamp at startup CurrentTimeStamp int64 - //asynchronously running padding goroutine numbers - GoNum int32 + //whether there is a running padding goroutine + running int32 } -var cores int = runtime.NumCPU() - func NewRingBuffer(bufferSize int64) *RingBuffer { p := PaddedInt{} p.Value = -1 @@ -75,7 +73,7 @@ func NewRingBuffer(bufferSize int64) *RingBuffer { wp: p, rp: p, bufferSize: bufferSize, - GoNum: 1, + running: 0, } } @@ -87,17 +85,20 @@ func (r *RingBuffer) Put(uid int64) (bool, error) { if currentReadPointer == -1 { currentReadPointer = 0 } + distance := currentWritePointer - currentReadPointer //write pointer catches read pointer, ringbuffer is full if distance == r.bufferSize-1 { return false, errors.New("ringbuffer is full! Rejected putting buffer") } - //(currentWritePointer + 1) mod r.bufferSize nextWriteIndex := (currentWritePointer + 1) & (r.bufferSize - 1) - if r.flags[nextWriteIndex].Value != CAN_PUT_FLAG { - return false, errors.New("slot is not in writable status") + //The flag at this location may not have been updated + time.Sleep(time.Microsecond) + if r.flags[nextWriteIndex].Value != CAN_PUT_FLAG { + return false, errors.New("slot is not in writable status") + } } r.slots[nextWriteIndex] = uid @@ -106,29 +107,43 @@ func (r *RingBuffer) Put(uid int64) (bool, error) { return true, nil } +//taking uid is a lock free operation to ensure the only padding goroutine can get enough time slices func (r *RingBuffer) Take() (int64, error) { - r.m.Lock() - defer r.m.Unlock() var uid int64 + var currentReadPointer int64 + var nextReadPointer int64 + + //atomically update r.rp.value if r.rp.Value != r.wp.Value + for { + currentReadPointer = r.rp.Value + nextReadPointer = currentReadPointer + if currentReadPointer < r.wp.Value { + nextReadPointer++ + } + if atomic.CompareAndSwapInt64(&r.rp.Value, currentReadPointer, nextReadPointer) { + break + } + } - if r.rp.Value != r.wp.Value { - r.rp.Value++ - } else { - return uid, errors.New("buffer is empty, rejected take buffer") + if r.wp.Value-currentReadPointer < r.bufferSize*r.PaddingFactor/100 { + go r.PaddingRingBuffer() } - if r.wp.Value-r.rp.Value < r.bufferSize*r.PaddingFactor/100 { - //limit the numbers of goroutine - if int(r.GoNum) <= 2*cores { - r.GoNum++ - go r.PaddingRingBuffer() + //if buffer is empty, wait a moment + if currentReadPointer == nextReadPointer { + running := false + for !running { + running = r.PaddingRingBuffer() + } + if currentReadPointer == nextReadPointer { + log.DefaultLogger.Warnf("buffer is empty") } } //check next slot flag is CAN_TAKE_FLAG - nextReadIndex := (r.rp.Value) & (r.bufferSize - 1) - if r.flags[nextReadIndex].Value != CAN_TAKE_FLAG { - return uid, errors.New("slot not in readable status") + nextReadIndex := nextReadPointer & (r.bufferSize - 1) + if atomic.LoadInt64(&r.flags[nextReadIndex].Value) != CAN_TAKE_FLAG { + return uid, errors.New("buffer is empty! Please request again") } uid = r.slots[nextReadIndex] @@ -136,28 +151,23 @@ func (r *RingBuffer) Take() (int64, error) { return uid, nil } -//allocate bits for uid -//workid + time + sequence +//allocate workid and timestamp for uid func (r *RingBuffer) Allocator() int64 { - var sequence int64 - timestampShift := r.SeqBits workidShift := r.TimeBits + r.SeqBits workid := r.WorkId - - r.m.Lock() timestamp := r.CurrentTimeStamp r.CurrentTimeStamp++ - r.m.Unlock() + var sequence int64 return timestamp< Date: Tue, 20 Sep 2022 22:44:21 +0800 Subject: [PATCH 14/45] fix --- components/pkg/utils/snowflake/snowflake.go | 1 + 1 file changed, 1 insertion(+) diff --git a/components/pkg/utils/snowflake/snowflake.go b/components/pkg/utils/snowflake/snowflake.go index 1241fb38a2..26ef286a61 100755 --- a/components/pkg/utils/snowflake/snowflake.go +++ b/components/pkg/utils/snowflake/snowflake.go @@ -22,6 +22,7 @@ import ( "strconv" "time" + // mysql driver _ "github.com/go-sql-driver/mysql" ) From ef9f588d8131ed8d7cd7d397a863a54ce7143bfa Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Tue, 20 Sep 2022 23:31:18 +0800 Subject: [PATCH 15/45] fix --- .../pkg/utils/snowflake/ringbuffer_test.go | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 components/pkg/utils/snowflake/ringbuffer_test.go diff --git a/components/pkg/utils/snowflake/ringbuffer_test.go b/components/pkg/utils/snowflake/ringbuffer_test.go new file mode 100644 index 0000000000..e5efed0f04 --- /dev/null +++ b/components/pkg/utils/snowflake/ringbuffer_test.go @@ -0,0 +1,36 @@ +package snowflake + +import ( + "testing" + "time" + + "github.com/stretchr/testify/assert" +) + +func TestPaddingRingBuffer(t *testing.T) { + rb := NewRingBuffer(8192) + + rb.TimeBits = 28 + rb.WorkIdBits = 22 + rb.SeqBits = 13 + rb.PaddingFactor = 50 + + s := "2022-01-01" + + var tmp time.Time + tmp, err := time.ParseInLocation("2006-01-02", s, time.Local) + assert.NoError(t, err) + startTime := tmp.Unix() + rb.CurrentTimeStamp = time.Now().Unix() - startTime + rb.PaddingRingBuffer() + + var uid int64 + for i := 0; i < 8192; i++ { + uid, err = rb.Take() + assert.NoError(t, err) + assert.NotEqual(t, uid, 0) + } + uid, err = rb.Take() + assert.NoError(t, err) + assert.NotEqual(t, uid, 0) +} From 251a53c7f8da01fd073ad4eb54445c3db69878a5 Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Tue, 20 Sep 2022 23:35:26 +0800 Subject: [PATCH 16/45] fix --- components/pkg/utils/snowflake/ringbuffer_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/components/pkg/utils/snowflake/ringbuffer_test.go b/components/pkg/utils/snowflake/ringbuffer_test.go index e5efed0f04..67e686e81f 100644 --- a/components/pkg/utils/snowflake/ringbuffer_test.go +++ b/components/pkg/utils/snowflake/ringbuffer_test.go @@ -1,3 +1,16 @@ +// +// Copyright 2021 Layotto Authors +// 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 snowflake import ( From 024fc697b600bd2f03cc33985c41f1da1d9fca64 Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Wed, 21 Sep 2022 10:21:31 +0800 Subject: [PATCH 17/45] add UT --- .../pkg/utils/snowflake/snowflake_test.go | 52 ++++++++++++++++++- .../snowflake/snowflake_sequencer_test.go | 8 ++- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/components/pkg/utils/snowflake/snowflake_test.go b/components/pkg/utils/snowflake/snowflake_test.go index d4d41bee79..535f6cd6a1 100644 --- a/components/pkg/utils/snowflake/snowflake_test.go +++ b/components/pkg/utils/snowflake/snowflake_test.go @@ -14,8 +14,10 @@ package snowflake import ( + "database/sql" "testing" + "github.com/DATA-DOG/go-sqlmock" "github.com/stretchr/testify/assert" ) @@ -31,12 +33,60 @@ func TestParseSnowflakeRingBufferMetadata(t *testing.T) { properties["startTime"] = "2022.01.01" _, err = ParseSnowflakeRingBufferMetadata(properties) assert.Error(t, err) + + properties["boostPower"] = "a" + _, err = ParseSnowflakeRingBufferMetadata(properties) + assert.Error(t, err) + + properties["paddingFactor"] = "a" + _, err = ParseSnowflakeRingBufferMetadata(properties) + assert.Error(t, err) + + properties["workerBits"] = "a" + _, err = ParseSnowflakeRingBufferMetadata(properties) + assert.Error(t, err) + + properties["timeBits"] = "a" + _, err = ParseSnowflakeRingBufferMetadata(properties) + assert.Error(t, err) + + properties["seqBits"] = "a" + _, err = ParseSnowflakeRingBufferMetadata(properties) + assert.Error(t, err) } func TestParseSnowflakeMysqlMetadata(t *testing.T) { properties := make(map[string]string) - properties["tableName"] = "layotto_sequence_snowflake" _, err := ParseSnowflakeMysqlMetadata(properties) assert.Error(t, err) + + properties["tableName"] = "layotto_sequence_snowflake" + _, err = ParseSnowflakeMysqlMetadata(properties) + assert.Error(t, err) +} + +func TestGetMysqlPort(t *testing.T) { + p := getMysqlPort() + assert.NotEmpty(t, p) +} + +func TestNewMysqlClient(t *testing.T) { + db, mock, err := sqlmock.New() + if err != nil { + t.Fatalf("an error '%s' was not expected when opening a stub database connection", err) + } + + mock.ExpectExec("CREATE TABLE").WillReturnResult(sqlmock.NewResult(1, 1)) + mock.ExpectBegin() + mock.ExpectQuery("SELECT HOST_NAME").WillReturnError(sql.ErrNoRows) + mock.ExpectExec("INSERT INTO").WillReturnResult(sqlmock.NewResult(1, 1)) + mock.ExpectQuery("SELECT ID").WillReturnRows(sqlmock.NewRows([]string{"id"}).AddRow(1)) + mock.ExpectCommit() + + m := MysqlMetadata{} + m.Db = db + workId, err := NewMysqlClient(m) + assert.NoError(t, err) + assert.Equal(t, workId, int64(1)) } diff --git a/components/sequencer/snowflake/snowflake_sequencer_test.go b/components/sequencer/snowflake/snowflake_sequencer_test.go index c13f83399f..313c2859a6 100755 --- a/components/sequencer/snowflake/snowflake_sequencer_test.go +++ b/components/sequencer/snowflake/snowflake_sequencer_test.go @@ -46,6 +46,13 @@ const ( key = "resource_xxx" ) +func TestInit(t *testing.T) { + s := NewSnowFlakeSequencer(log.DefaultLogger) + cfg := sequencer.Configuration{} + err := s.Init(cfg) + assert.Error(t, err) +} + func TestSnowFlakeSequence_GetNextId(t *testing.T) { db, mock, err := sqlmock.New() if err != nil { @@ -75,7 +82,6 @@ func TestSnowFlakeSequence_GetNextId(t *testing.T) { cfg.Properties["boostPower"] = boostPower cfg.Properties["paddingFactor"] = paddingFactor - cfg.Properties["scheduleInterval"] = scheduleInterval cfg.Properties["timeBits"] = timeBits cfg.Properties["workerBits"] = workerBits cfg.Properties["seqBits"] = seqBits From d6938459a8e7025e18df1a034ff7e97a31ce0a30 Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Wed, 21 Sep 2022 10:28:02 +0800 Subject: [PATCH 18/45] add UT --- .../sequencer/snowflake/snowflake_sequencer_test.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/components/sequencer/snowflake/snowflake_sequencer_test.go b/components/sequencer/snowflake/snowflake_sequencer_test.go index 313c2859a6..8784614443 100755 --- a/components/sequencer/snowflake/snowflake_sequencer_test.go +++ b/components/sequencer/snowflake/snowflake_sequencer_test.go @@ -35,13 +35,12 @@ const ( userName = "root" password = "123456" - boostPower = "3" - paddingFactor = "50" - scheduleInterval = "5" - timeBits = "28" - workerBits = "22" - seqBits = "13" - startTime = "2022-01-01" + boostPower = "3" + paddingFactor = "50" + timeBits = "28" + workerBits = "22" + seqBits = "13" + startTime = "2022-01-01" key = "resource_xxx" ) From a54e3ab07f2b878bcab466e742a62c4909479621 Mon Sep 17 00:00:00 2001 From: unknown <321642771@qq.com> Date: Sun, 25 Sep 2022 14:03:30 +0800 Subject: [PATCH 19/45] fix --- .../snowflake/snowflake_sequencer_test.go | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/components/sequencer/snowflake/snowflake_sequencer_test.go b/components/sequencer/snowflake/snowflake_sequencer_test.go index 8784614443..3ff59a3d6b 100755 --- a/components/sequencer/snowflake/snowflake_sequencer_test.go +++ b/components/sequencer/snowflake/snowflake_sequencer_test.go @@ -20,7 +20,6 @@ import ( "testing" "github.com/DATA-DOG/go-sqlmock" - mapset "github.com/deckarep/golang-set" _ "github.com/go-sql-driver/mysql" "github.com/stretchr/testify/assert" "mosn.io/pkg/log" @@ -45,13 +44,6 @@ const ( key = "resource_xxx" ) -func TestInit(t *testing.T) { - s := NewSnowFlakeSequencer(log.DefaultLogger) - cfg := sequencer.Configuration{} - err := s.Init(cfg) - assert.Error(t, err) -} - func TestSnowFlakeSequence_GetNextId(t *testing.T) { db, mock, err := sqlmock.New() if err != nil { @@ -90,8 +82,6 @@ func TestSnowFlakeSequence_GetNextId(t *testing.T) { assert.NoError(t, err) - mset := mapset.NewSet() - var falseUidNum int var preUid int64 var size int = 10000 @@ -105,10 +95,8 @@ func TestSnowFlakeSequence_GetNextId(t *testing.T) { } preUid = resp.NextId assert.NoError(t, err) - mset.Add(resp.NextId) } assert.Equal(t, falseUidNum, 0) - assert.Equal(t, size, mset.Cardinality()) } func TestSnowFlakeSequence_ParallelGetNextId(t *testing.T) { @@ -142,8 +130,6 @@ func TestSnowFlakeSequence_ParallelGetNextId(t *testing.T) { assert.NoError(t, err) - mset := mapset.NewSet() - var size int = 1000 var falseUidNum int var preUid int64 @@ -171,11 +157,9 @@ func TestSnowFlakeSequence_ParallelGetNextId(t *testing.T) { preUid = resp.NextId mu.Unlock() assert.NoError(t, err) - mset.Add(resp.NextId) } wg.Done() }() } wg.Wait() - assert.Equal(t, size*cores, mset.Cardinality()) } From 57c9766a4b7896992772d9399fee2593b5948552 Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Thu, 29 Sep 2022 22:38:04 +0800 Subject: [PATCH 20/45] add docs --- components/pkg/utils/snowflake/snowflake.go | 16 ++-- .../pkg/utils/snowflake/snowflake_test.go | 2 +- .../snowflake/snowflake_sequencer_test.go | 10 +- configs/config_snowflake.json | 87 ++++++++++++++++++ .../en/component_specs/sequencer/snowflake.md | 65 +++++++++++++ docs/img/sequencer/snowflake/snowflake_id.jpg | Bin 0 -> 32821 bytes .../zh/component_specs/sequencer/snowflake.md | 67 ++++++++++++++ 7 files changed, 233 insertions(+), 14 deletions(-) create mode 100644 configs/config_snowflake.json create mode 100644 docs/en/component_specs/sequencer/snowflake.md create mode 100755 docs/img/sequencer/snowflake/snowflake_id.jpg create mode 100644 docs/zh/component_specs/sequencer/snowflake.md diff --git a/components/pkg/utils/snowflake/snowflake.go b/components/pkg/utils/snowflake/snowflake.go index 26ef286a61..e9a16b3bdc 100755 --- a/components/pkg/utils/snowflake/snowflake.go +++ b/components/pkg/utils/snowflake/snowflake.go @@ -27,7 +27,7 @@ import ( ) const ( - mysqlUrl = "mysql" + mysqlHost = "mysqlHost" databaseName = "databaseName" tableName = "tableName" userName = "userName" @@ -40,6 +40,7 @@ const ( seqBits = "seqBits" startTime = "startTime" + defaultTableName = "layotto_sequencer_snowflake" defalutBoostPower = 3 defalutPaddingFactor = 50 defalutTimeBits = 28 @@ -123,15 +124,14 @@ type MysqlMetadata struct { TableName string Db *sql.DB //ip:port - MysqlUrl string + MysqlHost string } func ParseSnowflakeMysqlMetadata(properties map[string]string) (MysqlMetadata, error) { m := MysqlMetadata{} + m.TableName = defaultTableName if val, ok := properties[tableName]; ok && val != "" { m.TableName = val - } else { - return m, errors.New("mysql connect error: missing table name") } if val, ok := properties[databaseName]; ok && val != "" { m.DatabaseName = val @@ -148,10 +148,10 @@ func ParseSnowflakeMysqlMetadata(properties map[string]string) (MysqlMetadata, e } else { return m, errors.New("mysql connect error: missing password") } - if val, ok := properties[mysqlUrl]; ok && val != "" { - m.MysqlUrl = val + if val, ok := properties[mysqlHost]; ok && val != "" { + m.MysqlHost = val } else { - return m, errors.New("mysql connect error: missing mysqlurl") + return m, errors.New("mysql connect error: missing mysqlHost") } return m, nil } @@ -161,7 +161,7 @@ func NewMysqlClient(meta MysqlMetadata) (int64, error) { var workId int64 //for unit test if meta.Db == nil { - mysql := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=%s&parseTime=true&loc=Local", meta.UserName, meta.Password, meta.MysqlUrl, meta.DatabaseName, charset) + mysql := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=%s&parseTime=true&loc=Local", meta.UserName, meta.Password, meta.MysqlHost, meta.DatabaseName, charset) db, err := sql.Open("mysql", mysql) if err != nil { return workId, err diff --git a/components/pkg/utils/snowflake/snowflake_test.go b/components/pkg/utils/snowflake/snowflake_test.go index 535f6cd6a1..4a81561be3 100644 --- a/components/pkg/utils/snowflake/snowflake_test.go +++ b/components/pkg/utils/snowflake/snowflake_test.go @@ -61,7 +61,7 @@ func TestParseSnowflakeMysqlMetadata(t *testing.T) { _, err := ParseSnowflakeMysqlMetadata(properties) assert.Error(t, err) - properties["tableName"] = "layotto_sequence_snowflake" + properties["databaseName"] = "layotto_sequence_snowflake" _, err = ParseSnowflakeMysqlMetadata(properties) assert.Error(t, err) } diff --git a/components/sequencer/snowflake/snowflake_sequencer_test.go b/components/sequencer/snowflake/snowflake_sequencer_test.go index 8784614443..8785069350 100755 --- a/components/sequencer/snowflake/snowflake_sequencer_test.go +++ b/components/sequencer/snowflake/snowflake_sequencer_test.go @@ -29,9 +29,9 @@ import ( ) const ( - mysqlUrl = "localhost:3306" - databaseName = "layotto_sequence" - tableName = "layotto_sequence_snowflake" + mysqlHost = "localhost:3306" + databaseName = "layotto_sequencer" + tableName = "layotto_sequencer_snowflake" userName = "root" password = "123456" @@ -73,7 +73,7 @@ func TestSnowFlakeSequence_GetNextId(t *testing.T) { BiggerThan: make(map[string]int64), } - cfg.Properties["mysql"] = mysqlUrl + cfg.Properties["mysqlHost"] = mysqlHost cfg.Properties["databaseName"] = databaseName cfg.Properties["tableName"] = tableName cfg.Properties["userName"] = userName @@ -132,7 +132,7 @@ func TestSnowFlakeSequence_ParallelGetNextId(t *testing.T) { BiggerThan: make(map[string]int64), } - cfg.Properties["mysql"] = mysqlUrl + cfg.Properties["mysqlHost"] = mysqlHost cfg.Properties["databaseName"] = databaseName cfg.Properties["tableName"] = tableName cfg.Properties["userName"] = userName diff --git a/configs/config_snowflake.json b/configs/config_snowflake.json new file mode 100644 index 0000000000..6c28aef13b --- /dev/null +++ b/configs/config_snowflake.json @@ -0,0 +1,87 @@ +{ + "servers": [ + { + "default_log_path": "stdout", + "default_log_level": "DEBUG", + "routers": [ + { + "router_config_name": "actuator_dont_need_router" + } + ], + "listeners": [ + { + "name": "grpc", + "address": "127.0.0.1:34904", + "bind_port": true, + "filter_chains": [ + { + "filters": [ + { + "type": "grpc", + "config": { + "server_name": "runtime", + "grpc_config": { + "hellos": { + "helloworld": { + "type": "helloworld", + "hello": "greeting" + } + }, + "sequencer": { + "sequencer_demo": { + "type": "snowflake", + "metadata": { + "mysqlHost": "localhost:3306", + "userName": "root", + "password": "123456", + "databaseName": "layotto_sequencer", + "tableName": "layotto_sequencer_snowflake", + "boostPower": "3", + "paddingFactor": "50", + "timeBits": "28", + "workerBits": "22", + "seqBits": "13", + "startTime": "2022-01-01" + } + } + }, + "app": { + "app_id": "app1", + "grpc_callback_port": 9999 + } + } + } + } + ] + } + ] + }, + { + "name": "actuator", + "address": "127.0.0.1:34999", + "bind_port": true, + "filter_chains": [ + { + "filters": [ + { + "type": "proxy", + "config": { + "downstream_protocol": "Http1", + "upstream_protocol": "Http1", + "router_config_name": "actuator_dont_need_router" + } + } + ] + } + ], + "stream_filters": [ + { + "type": "actuator_filter" + } + ] + } + ] + } + ] + } + \ No newline at end of file diff --git a/docs/en/component_specs/sequencer/snowflake.md b/docs/en/component_specs/sequencer/snowflake.md new file mode 100644 index 0000000000..a25deb7565 --- /dev/null +++ b/docs/en/component_specs/sequencer/snowflake.md @@ -0,0 +1,65 @@ +# Snowflake + +## metadata fields + +Example: configs/config_snowflake.json + +| Field | Required | Description | +| ------------- | -------- | ------------------------------------------------------------ | +| mysqlHost | Y | mysql server address, such as localhost:3306 | +| userName | Y | mysql username | +| password | Y | mysql password | +| databaseName | Y | mysql database name | +| tableName | N | mysql table name | +| boostPower | N | RingBuffer expansion parameters, default value is 3,after expansion, buffersize = 8192 << 3 = 65536 | +| paddingFactor | N | when the percentage less than the total capacity, start filling the RingBuffer with UID. The value is between 0 and 100, default is 50 | +| timeBits | N | time id size, default value is 28 | +| workerBits | N | worker id size, default value is 22 | +| seqBits | N | sequence id size, default value is 13 | +| startTime | N | time base, default value is “2022-01-01” | + +## Overall design + +The overall design of the id generated by the snowflake algorithm is as follows: + +![img.jpg](../../../img/sequencer/snowflake/snowflake_id.jpg) + +## How to start mysql + +If you want to run the mysql demo, you need to start a mysql server with Docker first. + +```shell +docker pull mysql:latest +docker run --name snowflake -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d mysql +docker exec -it snowflake bash +mysql -uroot -p123456 +``` + +You need to create a new database: + +```mysql +CREATE DATABASE layotto_sequencer; +``` + +## Run layotto + +````shell +cd ${project_path}/cmd/layotto +go build +```` + +>If build reports an error, it can be executed in the root directory of the project `go mod vendor` + +Execute after the compilation is successful: + +````shell +./layotto start -c ../../configs/config_redis.json +```` + +## Run Demo + +````shell +cd ${project_path}/demo/sequencer/redis/ + go build -o client + ./client -s "sequencer_demo" +```` \ No newline at end of file diff --git a/docs/img/sequencer/snowflake/snowflake_id.jpg b/docs/img/sequencer/snowflake/snowflake_id.jpg new file mode 100755 index 0000000000000000000000000000000000000000..e25ebfcb56be23433c42e2628eade61bd56873d0 GIT binary patch literal 32821 zcmeFZ2UHYax-VJ?3P_TiGfD2cl0gInBxeK~Q9yDMP%@Hp&Y?jB1SBWP zIp^F!hg;5>Iivr%GjHx$^Ugizy#uROSFNtzwZFZ;{QbT{|3J?JHy+6;$^jS{7=SVO z51}$pf8GaR1f&5#Sp<3tcmUvByM}%3Dh@U_HZCsCb$l`cd^|jSY7$Z+GI|L}iFNfFHV*D}Jn)998^9F| zOw21-m{+f2f#hO%gWm&K#8*j}1!S&~s+(Z5IFJdxiAu*|y*~L>eQodP{MOYyG(0joHvVH` za$#|4d1ZBNePi?B@aXvD^bCG}@slnL0Q29-`gh9yKo>Dc*A*-*Of2l5bYWa^0}o7M ztgFld*GOd4u}vIESp?tUkll|;FKfkRy`!;D{@ii!It821!p(!9r2UDqe~vJ}{}5&W zPS{`RngsAc#=Js|Nen=MvkQ*TzSsZf_-zgDLW$vXI>QoXi~*GpJgALYn@`qs!-^cK|7FuH?gv1_p1Vfo>!WuAQbX%>ezM>HLLP z{%3XmO)~yl@{X2SK!auO=0)76>nar+sAnI$7)I~4vf6q`5Iq8xVSf;^KgjL?M;a02 z4>HF1yL6REfBt{aAWc_-fg?2VI~S?{LA;Ky{}Za@pPY^u8o+`lqDUEWo^8#UUNTNL z_D_2>o6nRBdT-;e*?PJa`!%A0`FKP$JsxTna_kkmP6nvU{+Bp@s;?t^*clgeXU6mD zPklGdkL*spbTfP-P1l~Clh?DfW2*4_V_2cc4Sl`bz}-8IzH3P})Aa3*L5qy!seuKH zuA^y3MSROTykn#H^;xEcUI=W$_?2rV9966{LLME^F-VS_e61Nu>0a#OH3^+nVEb-1 zp#yW4?s6o=ZCOi+^^;&-JlG#wYm?FnJgu{EBSn@QyfJ*jxzyDsbGLITWhAcWVhi=a z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|KfZkuTN?Si~}H^z=^G0Ob{~~4%iZ;^S9>ebre9-(qx$1`mpWy&{FCCP9f)?+}*`*U==ph@}V67n7{#?_~`}A`^{e15JdKN&u zzHgtY`60LX%ecnV0}%v_dHe0nlR&@@-wOH7e+V39-}Sxz6RQ<1${knt;gw1SI_=OB z%i@r0Pp`w?JGSyqhWhqGxChk6dsw#!SSw=3f?2v=1fO1m!4?Fem`nM?mJxTsM zLGcGs@jt~WNl?MC069Ro(yTYpG|GSjy8Fk(UqXw< z`rUPJAb%2o89LCPtNPz_uY?<6XWqtGD-LEF`@@9DFcJm}如果 build 报错,可以在项目根目录执行 `go mod vendor` + +编译成功后执行: + +````shell +./layotto start -c ../../configs/config_snowflake.json +```` + +## 运行 Demo + +````shell +cd ${project_path}/demo/sequencer/common/ + go build -o client + ./client -s "sequencer_demo" +```` \ No newline at end of file From 90bd7cb716039eb5d17f015f6a3564c66c7c3c1e Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Thu, 29 Sep 2022 23:14:50 +0800 Subject: [PATCH 21/45] fix --- components/pkg/utils/snowflake/ringbuffer_test.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/components/pkg/utils/snowflake/ringbuffer_test.go b/components/pkg/utils/snowflake/ringbuffer_test.go index 67e686e81f..0d9db68b10 100644 --- a/components/pkg/utils/snowflake/ringbuffer_test.go +++ b/components/pkg/utils/snowflake/ringbuffer_test.go @@ -38,12 +38,9 @@ func TestPaddingRingBuffer(t *testing.T) { rb.PaddingRingBuffer() var uid int64 - for i := 0; i < 8192; i++ { + for i := 0; i < 10000; i++ { uid, err = rb.Take() assert.NoError(t, err) assert.NotEqual(t, uid, 0) } - uid, err = rb.Take() - assert.NoError(t, err) - assert.NotEqual(t, uid, 0) } From 628eb41a858b0948ffe8916ffa2dd849699d673e Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Sat, 8 Oct 2022 17:28:07 +0800 Subject: [PATCH 22/45] fix --- components/pkg/utils/snowflake/ringbuffer.go | 30 +++++++------------ .../pkg/utils/snowflake/ringbuffer_test.go | 4 +-- .../snowflake/snowflake_sequencer_test.go | 9 +++--- .../en/component_specs/sequencer/snowflake.md | 6 ++-- .../zh/component_specs/sequencer/snowflake.md | 6 ++-- 5 files changed, 26 insertions(+), 29 deletions(-) diff --git a/components/pkg/utils/snowflake/ringbuffer.go b/components/pkg/utils/snowflake/ringbuffer.go index 72baa31757..f4d4c84ff4 100755 --- a/components/pkg/utils/snowflake/ringbuffer.go +++ b/components/pkg/utils/snowflake/ringbuffer.go @@ -15,9 +15,9 @@ package snowflake import ( "errors" + "runtime" "sync" "sync/atomic" - "time" "mosn.io/pkg/log" ) @@ -93,12 +93,9 @@ func (r *RingBuffer) Put(uid int64) (bool, error) { } nextWriteIndex := (currentWritePointer + 1) & (r.bufferSize - 1) - if r.flags[nextWriteIndex].Value != CAN_PUT_FLAG { - //The flag at this location may not have been updated - time.Sleep(time.Microsecond) - if r.flags[nextWriteIndex].Value != CAN_PUT_FLAG { - return false, errors.New("slot is not in writable status") - } + //The flag at this location may not have been updated after reading a uid, so yield the processor to update it + for r.flags[nextWriteIndex].Value != CAN_PUT_FLAG { + runtime.Gosched() } r.slots[nextWriteIndex] = uid @@ -113,12 +110,14 @@ func (r *RingBuffer) Take() (int64, error) { var currentReadPointer int64 var nextReadPointer int64 - //atomically update r.rp.value if r.rp.Value != r.wp.Value + //atomically update r.rp.value if r.rp.Value != r.wp.Value, otherwise wait until r.rp.Value != r.wp.Value for { currentReadPointer = r.rp.Value nextReadPointer = currentReadPointer if currentReadPointer < r.wp.Value { nextReadPointer++ + } else { + continue } if atomic.CompareAndSwapInt64(&r.rp.Value, currentReadPointer, nextReadPointer) { break @@ -129,21 +128,14 @@ func (r *RingBuffer) Take() (int64, error) { go r.PaddingRingBuffer() } - //if buffer is empty, wait a moment if currentReadPointer == nextReadPointer { - running := false - for !running { - running = r.PaddingRingBuffer() - } - if currentReadPointer == nextReadPointer { - log.DefaultLogger.Warnf("buffer is empty") - } + panic("read pointer is false") } - //check next slot flag is CAN_TAKE_FLAG nextReadIndex := nextReadPointer & (r.bufferSize - 1) + //check next slot flag is CAN_TAKE_FLAG if atomic.LoadInt64(&r.flags[nextReadIndex].Value) != CAN_TAKE_FLAG { - return uid, errors.New("buffer is empty! Please request again") + panic("slot is not in can take status") } uid = r.slots[nextReadIndex] @@ -186,7 +178,7 @@ func (r *RingBuffer) PaddingRingBuffer() bool { }() //there can only be one padding goroutine at a time, to ensure uids are strictly increasing - if !atomic.CompareAndSwapInt32(&r.running, 0, 1) { + if r.wp.Value-r.rp.Value > r.bufferSize*r.PaddingFactor/100 || !atomic.CompareAndSwapInt32(&r.running, 0, 1) { return false } diff --git a/components/pkg/utils/snowflake/ringbuffer_test.go b/components/pkg/utils/snowflake/ringbuffer_test.go index 0d9db68b10..5d4e376b05 100644 --- a/components/pkg/utils/snowflake/ringbuffer_test.go +++ b/components/pkg/utils/snowflake/ringbuffer_test.go @@ -21,7 +21,7 @@ import ( ) func TestPaddingRingBuffer(t *testing.T) { - rb := NewRingBuffer(8192) + rb := NewRingBuffer(65536) rb.TimeBits = 28 rb.WorkIdBits = 22 @@ -38,7 +38,7 @@ func TestPaddingRingBuffer(t *testing.T) { rb.PaddingRingBuffer() var uid int64 - for i := 0; i < 10000; i++ { + for i := 0; i < 100000; i++ { uid, err = rb.Take() assert.NoError(t, err) assert.NotEqual(t, uid, 0) diff --git a/components/sequencer/snowflake/snowflake_sequencer_test.go b/components/sequencer/snowflake/snowflake_sequencer_test.go index 653fbafd14..dcd614aefc 100755 --- a/components/sequencer/snowflake/snowflake_sequencer_test.go +++ b/components/sequencer/snowflake/snowflake_sequencer_test.go @@ -84,7 +84,7 @@ func TestSnowFlakeSequence_GetNextId(t *testing.T) { var falseUidNum int var preUid int64 - var size int = 10000 + var size int = 100000 for i := 0; i < size; i++ { resp, err := s.GetNextId(&sequencer.GetNextIdRequest{ Key: key, @@ -130,16 +130,16 @@ func TestSnowFlakeSequence_ParallelGetNextId(t *testing.T) { assert.NoError(t, err) - var size int = 1000 + var size int = 100000 var falseUidNum int var preUid int64 var cores int = runtime.NumCPU() var wg sync.WaitGroup var mu sync.Mutex - wg.Add(cores) + wg.Add(2 * cores) - for i := 0; i < cores; i++ { + for i := 0; i < 2*cores; i++ { go func() { defer func() { if x := recover(); x != nil { @@ -147,6 +147,7 @@ func TestSnowFlakeSequence_ParallelGetNextId(t *testing.T) { } }() for j := 0; j < size; j++ { + //assert next uid is bigger than previous mu.Lock() resp, err := s.GetNextId(&sequencer.GetNextIdRequest{ Key: key, diff --git a/docs/en/component_specs/sequencer/snowflake.md b/docs/en/component_specs/sequencer/snowflake.md index a25deb7565..fb54bbb731 100644 --- a/docs/en/component_specs/sequencer/snowflake.md +++ b/docs/en/component_specs/sequencer/snowflake.md @@ -11,8 +11,8 @@ Example: configs/config_snowflake.json | password | Y | mysql password | | databaseName | Y | mysql database name | | tableName | N | mysql table name | -| boostPower | N | RingBuffer expansion parameters, default value is 3,after expansion, buffersize = 8192 << 3 = 65536 | -| paddingFactor | N | when the percentage less than the total capacity, start filling the RingBuffer with UID. The value is between 0 and 100, default is 50 | +| boostPower | N | RingBuffer expansion parameters, default value is 3,after expansion, buffersize = 8192 << 3 = 65536. It can be appropriately increased when the id demand is large | +| paddingFactor | N | when the percentage less than the total capacity, start filling the RingBuffer with UID. The value is between 0 and 100, default is 50. It can be appropriately increased when the id demand is large | | timeBits | N | time id size, default value is 28 | | workerBits | N | worker id size, default value is 22 | | seqBits | N | sequence id size, default value is 13 | @@ -28,6 +28,8 @@ The overall design of the id generated by the snowflake algorithm is as follows: If you want to run the mysql demo, you need to start a mysql server with Docker first. +>If port 3306 is occupied by other services, you need to exit other services first + ```shell docker pull mysql:latest docker run --name snowflake -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d mysql diff --git a/docs/zh/component_specs/sequencer/snowflake.md b/docs/zh/component_specs/sequencer/snowflake.md index a2cd7dc148..70c3c141e1 100644 --- a/docs/zh/component_specs/sequencer/snowflake.md +++ b/docs/zh/component_specs/sequencer/snowflake.md @@ -11,8 +11,8 @@ | password | Y | mysql密码 | | databaseName | Y | mysql数据库名 | | tableName | N | mysql表名 | -| boostPower | N | RingBuffer扩容参数,默认3,扩容后buffersize = 8192 << 3=65536 | -| paddingFactor | N | 少于总容量的该百分比向RingBuffer中填充UID,取值为(0,100),默认为50 | +| boostPower | N | RingBuffer扩容参数,默认3,扩容后buffersize = 8192 << 3=65536。id需求量大时可适当调大 | +| paddingFactor | N | 少于总容量的该百分比向RingBuffer中填充UID,取值为(0,100),默认为50。id需求量大时可适当调大 | | timeBits | N | 时间戳所占位数大小。默认为28 | | workerBits | N | 机器id所占位数大小。默认为22 | | seqBits | N | 序列号所占位数大小。默认为13 | @@ -28,6 +28,8 @@ 如果想启动snowflake的demo,需要先用Docker启动一个mysql命令: +>如果3306端口被其他服务占用,需要先退出其他服务 + ```shell docker pull mysql:latest docker run --name snowflake -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d mysql From b9e87167dc27e1038ff6ce19747c5a8d34f5dd55 Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Sat, 8 Oct 2022 18:52:21 +0800 Subject: [PATCH 23/45] fix --- components/go.mod | 17 ++++++++++--- components/go.sum | 62 ++++++++++++++++++++++++++++++++--------------- go.sum | 2 -- 3 files changed, 57 insertions(+), 24 deletions(-) diff --git a/components/go.mod b/components/go.mod index 1a6551f1e3..3a8863dab7 100644 --- a/components/go.mod +++ b/components/go.mod @@ -8,39 +8,50 @@ require ( github.com/aliyun/aliyun-oss-go-sdk v2.2.0+incompatible github.com/apache/dubbo-go-hessian2 v1.10.2 github.com/apolloconfig/agollo/v4 v4.2.0 + github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878 // indirect github.com/aws/aws-sdk-go-v2 v1.16.4 github.com/aws/aws-sdk-go-v2/config v1.15.9 github.com/aws/aws-sdk-go-v2/credentials v1.12.4 github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.14 github.com/aws/aws-sdk-go-v2/service/s3 v1.26.10 github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f // indirect - github.com/deckarep/golang-set v1.8.0 + github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f // indirect github.com/go-redis/redis/v8 v8.8.0 github.com/go-sql-driver/mysql v1.6.0 github.com/go-zookeeper/zk v1.0.2 github.com/golang/mock v1.6.0 github.com/google/uuid v1.3.0 github.com/hashicorp/consul/api v1.3.0 + github.com/hashicorp/go-msgpack v1.1.5 // indirect + github.com/hashicorp/golang-lru v0.5.4 // indirect github.com/jarcoal/httpmock v1.2.0 github.com/jinzhu/copier v0.3.6-0.20220506024824-3e39b055319a github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect + github.com/miekg/dns v1.1.35 // indirect github.com/minio/minio-go/v7 v7.0.15 github.com/mitchellh/mapstructure v1.4.1 // indirect + github.com/nxadm/tail v1.4.8 // indirect github.com/pkg/errors v0.9.1 github.com/qiniu/go-sdk/v7 v7.11.1 + github.com/sergi/go-diff v1.2.0 // indirect github.com/spf13/afero v1.2.2 // indirect + github.com/spf13/cast v1.3.1 // indirect github.com/stretchr/testify v1.7.0 github.com/tencentyun/cos-go-sdk-v5 v0.7.33 + github.com/tidwall/pretty v1.2.0 // indirect github.com/valyala/fasthttp v1.26.0 go.beyondstorage.io/services/hdfs v0.3.0 go.beyondstorage.io/v5 v5.0.0 + go.etcd.io/etcd v0.5.0-alpha.5.0.20200910180754-dd1b699fc489 // indirect go.etcd.io/etcd/api/v3 v3.5.0 go.etcd.io/etcd/client/v3 v3.5.0 go.etcd.io/etcd/server/v3 v3.5.0 go.mongodb.org/mongo-driver v1.8.0 - go.uber.org/atomic v1.7.0 + go.uber.org/atomic v1.8.0 + go.uber.org/multierr v1.7.0 // indirect + go.uber.org/zap v1.18.1 // indirect golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect - golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5 // indirect + golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93 // indirect google.golang.org/grpc v1.38.0 mosn.io/api v1.1.0 mosn.io/mosn v1.1.0 diff --git a/components/go.sum b/components/go.sum index fb573f6185..b3580186ed 100644 --- a/components/go.sum +++ b/components/go.sum @@ -40,6 +40,7 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/HdrHistogram/hdrhistogram-go v1.0.1/go.mod h1:BWJ+nMSHY3L41Zj7CA3uXnloDp7xxV0YvstAE7nKTaM= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= @@ -86,8 +87,9 @@ github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb github.com/apolloconfig/agollo/v4 v4.2.0 h1:FkE8acffsUhnRnjyi37eOq6JpfUhQKuNccG2jXB3Mco= github.com/apolloconfig/agollo/v4 v4.2.0/go.mod h1:SuvTjtg0p4UlSzSbik+ibLRr6oR1xRsfy65QzP3GEAs= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= -github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da h1:8GUt8eRujhVEGZFFEjBj46YV4rDjvGrNxb0KMWYkL2I= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878 h1:EFSB7Zo9Eg91v7MJPVsifUysc/wPdN+NOnVe6bWbdBM= +github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878/go.mod h1:3AMJUQhVx52RsWOnlkpikZr01T/yAVN2gn0861vByNg= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= @@ -132,8 +134,9 @@ github.com/aws/smithy-go v1.11.2 h1:eG/N+CcUMAvsdffgMvjMKwfyDzIkjM6pfxMJ8Mzc6mE= github.com/aws/smithy-go v1.11.2/go.mod h1:3xHYmszWVx2c0kIwQeEVf9uSm4fYZt67FBJnwub1bgM= github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f h1:ZNv7On9kyUzm7fvRZumSyy/IUiSC7AzL0I1jKKtwooA= github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f/go.mod h1:AuiFmCCPBSrqvVMvuqFuk0qogytodnVFVSN5CeJB8Gc= -github.com/benbjohnson/clock v1.0.3 h1:vkLuvpK4fmtSCuo60+yC63p7y0BmQ8gm5ZXGuBCJyXg= github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= +github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= +github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -158,6 +161,8 @@ github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= +github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= @@ -180,8 +185,9 @@ github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e h1:Wf6HqHfScWJN9/ZjdUKyjop4mf3Qdd+1TvvltAvM3m8= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f h1:JOrtw2xFKzlg+cbHpyrpLDmnN1HqhBfnX7WDiW7eG2c= +github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= @@ -204,8 +210,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= -github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= -github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= github.com/denisenkom/go-mssqldb v0.0.0-20190707035753-2be1aa521ff4/go.mod h1:zAg7JM8CkOJ43xKXIj7eRO9kmWm/TW578qo+oDO6tuM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= @@ -426,16 +430,19 @@ github.com/hashicorp/consul/sdk v0.3.0 h1:UOxjlb4xVNF93jak1mzzoBatyFju9nrkxpVwIp github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI= github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-msgpack v0.5.3 h1:zKjpN5BK/P5lMYrLmBHdBULWbJ0XpYR+7NGzqkZzoD4= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-msgpack v1.1.5 h1:9byZdVjKTe5mce63pRVNP1L7UAmdHOTEMGehn6KvJWs= +github.com/hashicorp/go-msgpack v1.1.5/go.mod h1:gWVc3sv/wbDmR3rQsj1CAktEZzoz1YNK9NfGLXJ69/4= github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-plugin v1.0.1/go.mod h1:++UyYGoz3o5w9ZzAdZxtQKrWWP+iqPBn3cQptSMzBuY= +github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-rootcerts v1.0.0 h1:Rqb66Oo1X/eSV1x66xbDccZjhJigjg0+e82kpwzSwCI= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-sockaddr v1.0.0 h1:GeH6tui99pF4NJgfnhp+L6+FfobzVW3Ah46sLo0ICXs= @@ -449,8 +456,9 @@ github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/b github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= +github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= @@ -594,8 +602,9 @@ github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182aff github.com/maxatome/go-testdeep v1.11.0 h1:Tgh5efyCYyJFGUYiT0qxBSIDeXw0F5zSoatlou685kk= github.com/maxatome/go-testdeep v1.11.0/go.mod h1:011SgQ6efzZYAen6fDn4BqQ+lUR72ysdyKe7Dyogw70= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= -github.com/miekg/dns v1.1.25 h1:dFwPR6SfLtrSwgDcIq2bcU/gVutB4sNApq2HBdqcakg= github.com/miekg/dns v1.1.25/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= +github.com/miekg/dns v1.1.35 h1:oTfOaDH+mZkdcgdIjH6yBajRGtIwcwcaR+rt23ZSrJs= +github.com/miekg/dns v1.1.35/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= github.com/minio/md5-simd v1.1.0 h1:QPfiOqlZH+Cj9teu0t9b1nTBfPbyTl16Of5MeuShdK4= github.com/minio/md5-simd v1.1.0/go.mod h1:XpBqgZULrMYD3R+M28PcmP0CkI7PEMzB3U77ZrKZ0Gw= github.com/minio/minio-go/v7 v7.0.15 h1:r9/NhjJ+nXYrIYvbObhvc1wPj3YH1iDpJzz61uRKLyY= @@ -639,8 +648,9 @@ github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxzi github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U= -github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= @@ -671,8 +681,9 @@ github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJ github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= -github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c h1:Lgl0gzECD8GnQ5QCWA8o6BtfL6mDH5rQgM4/fX3avOs= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= +github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pborman/getopt v0.0.0-20180729010549-6fdd0a2c7117/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= @@ -691,6 +702,7 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM= github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= @@ -708,6 +720,7 @@ github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6T github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= @@ -718,6 +731,7 @@ github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16 github.com/prometheus/common v0.26.0 h1:iMAkS2TDoNWnKM+Kopnx/8tnEStIfpYA0ur0xQzzhMQ= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= @@ -750,8 +764,9 @@ github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= +github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= +github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/shirou/gopsutil v3.20.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil/v3 v3.20.11/go.mod h1:igHnfak0qnw1biGeI2qKQvu0ZkwvEkUcCLlYhZzdr/4= github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= @@ -778,8 +793,9 @@ github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasO github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= -github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= +github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= @@ -815,8 +831,9 @@ github.com/tencentyun/cos-go-sdk-v5 v0.7.33 h1:5jmJU7U/1nf/7ZPDkrUL8KlF1oDUzTHsd github.com/tencentyun/cos-go-sdk-v5 v0.7.33/go.mod h1:4E4+bQ2gBVJcgEC9Cufwylio4mXOct2iu05WjgEBx1o= github.com/tevid/gohamcrest v1.1.1 h1:ou+xSqlIw1xfGTg1uq1nif/htZ2S3EzRqLm2BP+tYU0= github.com/tevid/gohamcrest v1.1.1/go.mod h1:3UvtWlqm8j5JbwYZh80D/PVBt0mJ1eJiYgZMibh0H/k= -github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= +github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= +github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20200427203606-3cfed13b9966/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= @@ -825,6 +842,7 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1 github.com/toolkits/concurrent v0.0.0-20150624120057-a4371d70e3e3/go.mod h1:QDlpd3qS71vYtakd2hmdpqhJ9nwv6mD6A30bQ1BPBFE= github.com/trainyao/go-maglev v0.0.0-20200611125015-4c1ae64d96a8 h1:o6jtI8/BV93ZCw681cNVMjyvLfnBboUP/lBOfmkb4Pg= github.com/trainyao/go-maglev v0.0.0-20200611125015-4c1ae64d96a8/go.mod h1:VBsRn0SDTltC3/SzN6SgXlQtmBk6U5sf0KW+eT+WMbc= +github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/uber/jaeger-client-go v2.25.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= github.com/uber/jaeger-lib v2.4.0+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= @@ -872,8 +890,9 @@ go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= -go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738 h1:VcrIfasaLFkyjk6KNlXQSzO+B0fZcnECiDrKJsfxka0= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= +go.etcd.io/etcd v0.5.0-alpha.5.0.20200910180754-dd1b699fc489 h1:1JFLBqwIgdyHN1ZtgjTBwO+blA6gVOmZurpiMEsETKo= +go.etcd.io/etcd v0.5.0-alpha.5.0.20200910180754-dd1b699fc489/go.mod h1:yVHk9ub3CSBatqGNg7GRmsnfLWtoW60w4eDYfh7vHDg= go.etcd.io/etcd/api/v3 v3.5.0-alpha.0/go.mod h1:mPcW6aZJukV6Aa81LSKpBjQXTWlXB5r74ymPoSWa3Sw= go.etcd.io/etcd/api/v3 v3.5.0 h1:GsV3S+OfZEOCNXdtNkBSR7kgLobAa/SO6tCxRa0GAYw= go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= @@ -933,8 +952,9 @@ go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/atomic v1.8.0 h1:CUhrE4N1rqSE6FM9ecihEjRkLQu8cDfgDyoOs83mEY4= +go.uber.org/atomic v1.8.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/automaxprocs v1.3.0 h1:II28aZoGdaglS5vVNnspf28lnZpXScxtIozx1lAjdb0= go.uber.org/automaxprocs v1.3.0/go.mod h1:9CWT6lKIep8U41DDaPiH6eFscnTyjfTANNQNx6LrIcA= go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0= @@ -942,15 +962,17 @@ go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= -go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= +go.uber.org/multierr v1.7.0 h1:zaiO/rmgFjbmCXdSYJWQcdvOCsthmdaHfr3Gm2Kx4Ec= +go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.15.0/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc= go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ= -go.uber.org/zap v1.17.0 h1:MTjgFu6ZLKvY6Pvaqk97GlxNBuMpV4Hy/3P6tRGlI2U= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= +go.uber.org/zap v1.18.1 h1:CSUJ2mjFszzEWt4CdKISEuChVIXGBn3lAPwkRGyVrc4= +go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= golang.org/x/arch v0.0.0-20180920145803-b19384d3c130/go.mod h1:cYlCBUl1MsqxdiKgmc4uh7TxZfWSFLOGSRR090WDxt8= golang.org/x/arch v0.0.0-20200826200359-b19915210f00 h1:cfd5G6xu8iZTFmjBYVemyBmE/sTf0A3vpE3BmoOuLCI= golang.org/x/arch v0.0.0-20200826200359-b19915210f00/go.mod h1:flIaEI6LNU6xOCD5PaJvn9wGP0agmIOqjrtsKGRguv4= @@ -1063,8 +1085,8 @@ golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5 h1:Lm4OryKCca1vehdsWogr9N4t7NfZxLbJoc/H0w4K4S4= -golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93 h1:alLDrZkL34Y2bnGHfvC1CYBRBXCXgx8AC2vY4MRtYX4= +golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1181,6 +1203,7 @@ golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190424220101-1e8e1cfdf96b/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= @@ -1202,6 +1225,7 @@ golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= diff --git a/go.sum b/go.sum index c8210bc949..f35520b46f 100644 --- a/go.sum +++ b/go.sum @@ -372,8 +372,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= -github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= -github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= github.com/deepmap/oapi-codegen v1.3.6/go.mod h1:aBozjEveG+33xPiP55Iw/XbVkhtZHEGLq3nxlX0+hfU= github.com/deepmap/oapi-codegen v1.8.1/go.mod h1:YLgSKSDv/bZQB7N4ws6luhozi3cEdRktEqrX88CvjIw= github.com/denisenkom/go-mssqldb v0.0.0-20190707035753-2be1aa521ff4/go.mod h1:zAg7JM8CkOJ43xKXIj7eRO9kmWm/TW578qo+oDO6tuM= From f53dc31ffcb1fddbbb8a5d262c23d91b8eef2b98 Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Sat, 8 Oct 2022 18:57:26 +0800 Subject: [PATCH 24/45] fix --- go.sum | 1 - 1 file changed, 1 deletion(-) diff --git a/go.sum b/go.sum index f35520b46f..40f800514b 100644 --- a/go.sum +++ b/go.sum @@ -1677,7 +1677,6 @@ golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93 h1:alLDrZkL34Y2bnGHfvC1CYBRBXCXgx8AC2vY4MRtYX4= golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= From 61a0d4c3f7ebf7dde4334268347cc22b6f2893ec Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Sat, 8 Oct 2022 19:08:14 +0800 Subject: [PATCH 25/45] fix --- components/go.mod | 14 +------------- components/go.sum | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/components/go.mod b/components/go.mod index 3a8863dab7..1fbfc84e52 100644 --- a/components/go.mod +++ b/components/go.mod @@ -14,8 +14,7 @@ require ( github.com/aws/aws-sdk-go-v2/credentials v1.12.4 github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.14 github.com/aws/aws-sdk-go-v2/service/s3 v1.26.10 - github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f // indirect - github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f // indirect + github.com/dapr/components-contrib v1.5.2 github.com/go-redis/redis/v8 v8.8.0 github.com/go-sql-driver/mysql v1.6.0 github.com/go-zookeeper/zk v1.0.2 @@ -26,16 +25,9 @@ require ( github.com/hashicorp/golang-lru v0.5.4 // indirect github.com/jarcoal/httpmock v1.2.0 github.com/jinzhu/copier v0.3.6-0.20220506024824-3e39b055319a - github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect - github.com/miekg/dns v1.1.35 // indirect github.com/minio/minio-go/v7 v7.0.15 - github.com/mitchellh/mapstructure v1.4.1 // indirect - github.com/nxadm/tail v1.4.8 // indirect github.com/pkg/errors v0.9.1 github.com/qiniu/go-sdk/v7 v7.11.1 - github.com/sergi/go-diff v1.2.0 // indirect - github.com/spf13/afero v1.2.2 // indirect - github.com/spf13/cast v1.3.1 // indirect github.com/stretchr/testify v1.7.0 github.com/tencentyun/cos-go-sdk-v5 v0.7.33 github.com/tidwall/pretty v1.2.0 // indirect @@ -48,10 +40,6 @@ require ( go.etcd.io/etcd/server/v3 v3.5.0 go.mongodb.org/mongo-driver v1.8.0 go.uber.org/atomic v1.8.0 - go.uber.org/multierr v1.7.0 // indirect - go.uber.org/zap v1.18.1 // indirect - golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect - golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93 // indirect google.golang.org/grpc v1.38.0 mosn.io/api v1.1.0 mosn.io/mosn v1.1.0 diff --git a/components/go.sum b/components/go.sum index b3580186ed..ec12a73bad 100644 --- a/components/go.sum +++ b/components/go.sum @@ -41,6 +41,8 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= +github.com/DataDog/zstd v1.3.6-0.20190409195224-796139022798/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= +github.com/DataDog/zstd v1.4.6-0.20210211175136-c6db21d202f4/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/HdrHistogram/hdrhistogram-go v1.0.1/go.mod h1:BWJ+nMSHY3L41Zj7CA3uXnloDp7xxV0YvstAE7nKTaM= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= @@ -134,6 +136,7 @@ github.com/aws/smithy-go v1.11.2 h1:eG/N+CcUMAvsdffgMvjMKwfyDzIkjM6pfxMJ8Mzc6mE= github.com/aws/smithy-go v1.11.2/go.mod h1:3xHYmszWVx2c0kIwQeEVf9uSm4fYZt67FBJnwub1bgM= github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f h1:ZNv7On9kyUzm7fvRZumSyy/IUiSC7AzL0I1jKKtwooA= github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f/go.mod h1:AuiFmCCPBSrqvVMvuqFuk0qogytodnVFVSN5CeJB8Gc= +github.com/beefsack/go-rate v0.0.0-20180408011153-efa7637bb9b6/go.mod h1:6YNgTHLutezwnBvyneBbwvB8C82y3dcoOj5EQJIdGXA= github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= @@ -161,6 +164,7 @@ github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/cinience/go_rocketmq v0.0.2/go.mod h1:2YNY7emT546dcFpMEWLesmAEi4ndW7+tX5VfNf1Zsgs= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= @@ -437,6 +441,7 @@ github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9 github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-msgpack v1.1.5 h1:9byZdVjKTe5mce63pRVNP1L7UAmdHOTEMGehn6KvJWs= github.com/hashicorp/go-msgpack v1.1.5/go.mod h1:gWVc3sv/wbDmR3rQsj1CAktEZzoz1YNK9NfGLXJ69/4= github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o= @@ -605,6 +610,8 @@ github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3N github.com/miekg/dns v1.1.25/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.35 h1:oTfOaDH+mZkdcgdIjH6yBajRGtIwcwcaR+rt23ZSrJs= github.com/miekg/dns v1.1.35/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= +github.com/minio/highwayhash v1.0.0/go.mod h1:xQboMTeM9nY9v/LlAOxFctujiv5+Aq2hR5dxBpaMbdc= +github.com/minio/highwayhash v1.0.1/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= github.com/minio/md5-simd v1.1.0 h1:QPfiOqlZH+Cj9teu0t9b1nTBfPbyTl16Of5MeuShdK4= github.com/minio/md5-simd v1.1.0/go.mod h1:XpBqgZULrMYD3R+M28PcmP0CkI7PEMzB3U77ZrKZ0Gw= github.com/minio/minio-go/v7 v7.0.15 h1:r9/NhjJ+nXYrIYvbObhvc1wPj3YH1iDpJzz61uRKLyY= @@ -684,6 +691,7 @@ github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIw github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pborman/getopt v0.0.0-20180729010549-6fdd0a2c7117/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= @@ -764,6 +772,8 @@ github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/sendgrid/rest v2.6.3+incompatible/go.mod h1:kXX7q3jZtJXK5c5qK83bSGMdV6tsOE70KbHoqJls4lE= +github.com/sendgrid/sendgrid-go v3.5.0+incompatible/go.mod h1:QRQt+LX/NmgVEvmdRw0VT/QgUn499+iza2FnDca9fg8= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= @@ -796,6 +806,7 @@ github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTd github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cobra v0.0.0-20181021141114-fe5e611709b0/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= @@ -831,9 +842,17 @@ github.com/tencentyun/cos-go-sdk-v5 v0.7.33 h1:5jmJU7U/1nf/7ZPDkrUL8KlF1oDUzTHsd github.com/tencentyun/cos-go-sdk-v5 v0.7.33/go.mod h1:4E4+bQ2gBVJcgEC9Cufwylio4mXOct2iu05WjgEBx1o= github.com/tevid/gohamcrest v1.1.1 h1:ou+xSqlIw1xfGTg1uq1nif/htZ2S3EzRqLm2BP+tYU0= github.com/tevid/gohamcrest v1.1.1/go.mod h1:3UvtWlqm8j5JbwYZh80D/PVBt0mJ1eJiYgZMibh0H/k= +github.com/tidwall/gjson v1.2.1/go.mod h1:c/nTNbUr0E0OrXEhq1pwa8iEgc2DOt4ZZqAt1HtCkPA= +github.com/tidwall/gjson v1.8.0/go.mod h1:5/xDoumyyDNerp2U36lyolv46b3uF/9Bu6OfyQ9GImk= +github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E= +github.com/tidwall/match v1.0.3/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= +github.com/tidwall/pretty v0.0.0-20190325153808-1166b9ac2b65/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= +github.com/tidwall/pretty v1.1.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tklauser/go-sysconf v0.3.6/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI= +github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20200427203606-3cfed13b9966/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= @@ -973,6 +992,7 @@ go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= go.uber.org/zap v1.18.1 h1:CSUJ2mjFszzEWt4CdKISEuChVIXGBn3lAPwkRGyVrc4= go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= +goji.io v2.0.2+incompatible/go.mod h1:sbqFwrtqZACxLBTQcdgVjFh54yGVCvwq8+w49MVMMIk= golang.org/x/arch v0.0.0-20180920145803-b19384d3c130/go.mod h1:cYlCBUl1MsqxdiKgmc4uh7TxZfWSFLOGSRR090WDxt8= golang.org/x/arch v0.0.0-20200826200359-b19915210f00 h1:cfd5G6xu8iZTFmjBYVemyBmE/sTf0A3vpE3BmoOuLCI= golang.org/x/arch v0.0.0-20200826200359-b19915210f00/go.mod h1:flIaEI6LNU6xOCD5PaJvn9wGP0agmIOqjrtsKGRguv4= @@ -1085,6 +1105,7 @@ golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93 h1:alLDrZkL34Y2bnGHfvC1CYBRBXCXgx8AC2vY4MRtYX4= golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1203,6 +1224,9 @@ golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190424220101-1e8e1cfdf96b/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= From 46a493d0e982dbda9f9694a9665f6c50d18c4c0d Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Sun, 9 Oct 2022 19:41:14 +0800 Subject: [PATCH 26/45] fix --- components/go.mod | 15 +- components/go.sum | 26 +-- .../pkg/utils/{snowflake => }/snowflake.go | 154 ++++++-------- components/pkg/utils/snowflake/ringbuffer.go | 197 ------------------ .../pkg/utils/snowflake/ringbuffer_test.go | 46 ---- .../utils/{snowflake => }/snowflake_test.go | 53 ++--- .../snowflake/snowflake_sequencer.go | 82 +++++--- .../snowflake/snowflake_sequencer_test.go | 12 +- components/sequencer/test/main1/main.go | 81 +++++++ components/sequencer/test/main2/main.go | 104 +++++++++ configs/config_snowflake.json | 2 - .../en/component_specs/sequencer/snowflake.md | 4 +- .../zh/component_specs/sequencer/snowflake.md | 2 - go.sum | 1 + 14 files changed, 347 insertions(+), 432 deletions(-) rename components/pkg/utils/{snowflake => }/snowflake.go (68%) delete mode 100755 components/pkg/utils/snowflake/ringbuffer.go delete mode 100644 components/pkg/utils/snowflake/ringbuffer_test.go rename components/pkg/utils/{snowflake => }/snowflake_test.go (63%) create mode 100644 components/sequencer/test/main1/main.go create mode 100644 components/sequencer/test/main2/main.go diff --git a/components/go.mod b/components/go.mod index 1fbfc84e52..9328b94b07 100644 --- a/components/go.mod +++ b/components/go.mod @@ -14,7 +14,9 @@ require ( github.com/aws/aws-sdk-go-v2/credentials v1.12.4 github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.14 github.com/aws/aws-sdk-go-v2/service/s3 v1.26.10 - github.com/dapr/components-contrib v1.5.2 + github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f // indirect + github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f // indirect + github.com/deckarep/golang-set v1.8.0 github.com/go-redis/redis/v8 v8.8.0 github.com/go-sql-driver/mysql v1.6.0 github.com/go-zookeeper/zk v1.0.2 @@ -25,9 +27,16 @@ require ( github.com/hashicorp/golang-lru v0.5.4 // indirect github.com/jarcoal/httpmock v1.2.0 github.com/jinzhu/copier v0.3.6-0.20220506024824-3e39b055319a + github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect + github.com/miekg/dns v1.1.35 // indirect github.com/minio/minio-go/v7 v7.0.15 + github.com/mitchellh/mapstructure v1.4.1 // indirect + github.com/nxadm/tail v1.4.8 // indirect github.com/pkg/errors v0.9.1 github.com/qiniu/go-sdk/v7 v7.11.1 + github.com/sergi/go-diff v1.2.0 // indirect + github.com/spf13/afero v1.2.2 // indirect + github.com/spf13/cast v1.3.1 // indirect github.com/stretchr/testify v1.7.0 github.com/tencentyun/cos-go-sdk-v5 v0.7.33 github.com/tidwall/pretty v1.2.0 // indirect @@ -40,6 +49,10 @@ require ( go.etcd.io/etcd/server/v3 v3.5.0 go.mongodb.org/mongo-driver v1.8.0 go.uber.org/atomic v1.8.0 + go.uber.org/multierr v1.7.0 // indirect + go.uber.org/zap v1.18.1 // indirect + golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect + golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93 // indirect google.golang.org/grpc v1.38.0 mosn.io/api v1.1.0 mosn.io/mosn v1.1.0 diff --git a/components/go.sum b/components/go.sum index ec12a73bad..b6f6983ffa 100644 --- a/components/go.sum +++ b/components/go.sum @@ -41,8 +41,6 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/DataDog/zstd v1.3.6-0.20190409195224-796139022798/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= -github.com/DataDog/zstd v1.4.6-0.20210211175136-c6db21d202f4/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/HdrHistogram/hdrhistogram-go v1.0.1/go.mod h1:BWJ+nMSHY3L41Zj7CA3uXnloDp7xxV0YvstAE7nKTaM= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= @@ -136,7 +134,6 @@ github.com/aws/smithy-go v1.11.2 h1:eG/N+CcUMAvsdffgMvjMKwfyDzIkjM6pfxMJ8Mzc6mE= github.com/aws/smithy-go v1.11.2/go.mod h1:3xHYmszWVx2c0kIwQeEVf9uSm4fYZt67FBJnwub1bgM= github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f h1:ZNv7On9kyUzm7fvRZumSyy/IUiSC7AzL0I1jKKtwooA= github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f/go.mod h1:AuiFmCCPBSrqvVMvuqFuk0qogytodnVFVSN5CeJB8Gc= -github.com/beefsack/go-rate v0.0.0-20180408011153-efa7637bb9b6/go.mod h1:6YNgTHLutezwnBvyneBbwvB8C82y3dcoOj5EQJIdGXA= github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= @@ -164,7 +161,6 @@ github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/cinience/go_rocketmq v0.0.2/go.mod h1:2YNY7emT546dcFpMEWLesmAEi4ndW7+tX5VfNf1Zsgs= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= @@ -214,6 +210,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= +github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= +github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= github.com/denisenkom/go-mssqldb v0.0.0-20190707035753-2be1aa521ff4/go.mod h1:zAg7JM8CkOJ43xKXIj7eRO9kmWm/TW578qo+oDO6tuM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= @@ -441,7 +439,6 @@ github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9 github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= -github.com/hashicorp/go-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-msgpack v1.1.5 h1:9byZdVjKTe5mce63pRVNP1L7UAmdHOTEMGehn6KvJWs= github.com/hashicorp/go-msgpack v1.1.5/go.mod h1:gWVc3sv/wbDmR3rQsj1CAktEZzoz1YNK9NfGLXJ69/4= github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o= @@ -610,8 +607,6 @@ github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3N github.com/miekg/dns v1.1.25/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.35 h1:oTfOaDH+mZkdcgdIjH6yBajRGtIwcwcaR+rt23ZSrJs= github.com/miekg/dns v1.1.35/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= -github.com/minio/highwayhash v1.0.0/go.mod h1:xQboMTeM9nY9v/LlAOxFctujiv5+Aq2hR5dxBpaMbdc= -github.com/minio/highwayhash v1.0.1/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= github.com/minio/md5-simd v1.1.0 h1:QPfiOqlZH+Cj9teu0t9b1nTBfPbyTl16Of5MeuShdK4= github.com/minio/md5-simd v1.1.0/go.mod h1:XpBqgZULrMYD3R+M28PcmP0CkI7PEMzB3U77ZrKZ0Gw= github.com/minio/minio-go/v7 v7.0.15 h1:r9/NhjJ+nXYrIYvbObhvc1wPj3YH1iDpJzz61uRKLyY= @@ -691,7 +686,6 @@ github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIw github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pborman/getopt v0.0.0-20180729010549-6fdd0a2c7117/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= @@ -772,8 +766,6 @@ github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/sendgrid/rest v2.6.3+incompatible/go.mod h1:kXX7q3jZtJXK5c5qK83bSGMdV6tsOE70KbHoqJls4lE= -github.com/sendgrid/sendgrid-go v3.5.0+incompatible/go.mod h1:QRQt+LX/NmgVEvmdRw0VT/QgUn499+iza2FnDca9fg8= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= @@ -806,7 +798,6 @@ github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTd github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cobra v0.0.0-20181021141114-fe5e611709b0/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= @@ -842,17 +833,9 @@ github.com/tencentyun/cos-go-sdk-v5 v0.7.33 h1:5jmJU7U/1nf/7ZPDkrUL8KlF1oDUzTHsd github.com/tencentyun/cos-go-sdk-v5 v0.7.33/go.mod h1:4E4+bQ2gBVJcgEC9Cufwylio4mXOct2iu05WjgEBx1o= github.com/tevid/gohamcrest v1.1.1 h1:ou+xSqlIw1xfGTg1uq1nif/htZ2S3EzRqLm2BP+tYU0= github.com/tevid/gohamcrest v1.1.1/go.mod h1:3UvtWlqm8j5JbwYZh80D/PVBt0mJ1eJiYgZMibh0H/k= -github.com/tidwall/gjson v1.2.1/go.mod h1:c/nTNbUr0E0OrXEhq1pwa8iEgc2DOt4ZZqAt1HtCkPA= -github.com/tidwall/gjson v1.8.0/go.mod h1:5/xDoumyyDNerp2U36lyolv46b3uF/9Bu6OfyQ9GImk= -github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E= -github.com/tidwall/match v1.0.3/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v0.0.0-20190325153808-1166b9ac2b65/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= -github.com/tidwall/pretty v1.1.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= -github.com/tklauser/go-sysconf v0.3.6/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI= -github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20200427203606-3cfed13b9966/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= @@ -992,7 +975,6 @@ go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= go.uber.org/zap v1.18.1 h1:CSUJ2mjFszzEWt4CdKISEuChVIXGBn3lAPwkRGyVrc4= go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= -goji.io v2.0.2+incompatible/go.mod h1:sbqFwrtqZACxLBTQcdgVjFh54yGVCvwq8+w49MVMMIk= golang.org/x/arch v0.0.0-20180920145803-b19384d3c130/go.mod h1:cYlCBUl1MsqxdiKgmc4uh7TxZfWSFLOGSRR090WDxt8= golang.org/x/arch v0.0.0-20200826200359-b19915210f00 h1:cfd5G6xu8iZTFmjBYVemyBmE/sTf0A3vpE3BmoOuLCI= golang.org/x/arch v0.0.0-20200826200359-b19915210f00/go.mod h1:flIaEI6LNU6xOCD5PaJvn9wGP0agmIOqjrtsKGRguv4= @@ -1105,7 +1087,6 @@ golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93 h1:alLDrZkL34Y2bnGHfvC1CYBRBXCXgx8AC2vY4MRtYX4= golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1224,9 +1205,6 @@ golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190424220101-1e8e1cfdf96b/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= diff --git a/components/pkg/utils/snowflake/snowflake.go b/components/pkg/utils/snowflake.go similarity index 68% rename from components/pkg/utils/snowflake/snowflake.go rename to components/pkg/utils/snowflake.go index e9a16b3bdc..ac2f8620f3 100755 --- a/components/pkg/utils/snowflake/snowflake.go +++ b/components/pkg/utils/snowflake.go @@ -11,7 +11,7 @@ // 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 snowflake +package utils import ( "database/sql" @@ -27,60 +27,75 @@ import ( ) const ( - mysqlHost = "mysqlHost" - databaseName = "databaseName" - tableName = "tableName" - userName = "userName" - password = "password" - charset = "utf8" - boostPower = "boostPower" - paddingFactor = "paddingFactor" - timeBits = "timeBits" - workerBits = "workerBits" - seqBits = "seqBits" - startTime = "startTime" - - defaultTableName = "layotto_sequencer_snowflake" - defalutBoostPower = 3 - defalutPaddingFactor = 50 - defalutTimeBits = 28 - defalutWorkerBits = 22 - defalutSeqBits = 13 - defalutStartTime = "2022-01-01" + mysqlHost = "mysqlHost" + mysqlDatabaseName = "databaseName" + mysqlTableName = "tableName" + mysqlUserName = "userName" + mysqlPassword = "password" + mysqlCharset = "utf8" + timeBits = "timeBits" + workerBits = "workerBits" + seqBits = "seqBits" + startTime = "startTime" + + defaultMysqlTableName = "layotto_sequencer_snowflake" + defalutTimeBits = 28 + defalutWorkerBits = 22 + defalutSeqBits = 13 + defalutStartTime = "2022-01-01" ) type SnowflakeMetadata struct { - MysqlMetadata *MysqlMetadata - RingBufferMetadata *RingBufferMetadata - LogInfo bool -} + // MysqlMetadata + UserName string + Password string + DatabaseName string + TableName string + Db *sql.DB + //ip:port + MysqlHost string -type RingBufferMetadata struct { - //bufferSize = maxSeq << BoostPower, defalut BoostPower = 3 - BoostPower int64 - PaddingFactor int64 - WorkIdBits int64 - TimeBits int64 - SeqBits int64 - StartTime int64 + WorkIdBits int64 + TimeBits int64 + SeqBits int64 + StartTime int64 + WorkId int64 + LogInfo bool } -func ParseSnowflakeRingBufferMetadata(properties map[string]string) (RingBufferMetadata, error) { - metadata := RingBufferMetadata{} - +func ParseSnowflakeMetadata(properties map[string]string) (SnowflakeMetadata, error) { + metadata := SnowflakeMetadata{} var err error - metadata.BoostPower = defalutBoostPower - if val, ok := properties[boostPower]; ok && val != "" { - if metadata.BoostPower, err = strconv.ParseInt(val, 10, 64); err != nil { - return metadata, err - } + + metadata.TableName = defaultTableName + if val, ok := properties[mysqlTableName]; ok && val != "" { + metadata.TableName = val } - metadata.PaddingFactor = defalutPaddingFactor - if val, ok := properties[paddingFactor]; ok && val != "" { - if metadata.PaddingFactor, err = strconv.ParseInt(val, 10, 64); err != nil { - return metadata, err - } + + if val, ok := properties[mysqlDatabaseName]; ok && val != "" { + metadata.DatabaseName = val + } else { + return metadata, errors.New("mysql connect error: missing database name") + } + + if val, ok := properties[mysqlUserName]; ok && val != "" { + metadata.UserName = val + } else { + return metadata, errors.New("mysql connect error: missing username") } + + if val, ok := properties[mysqlPassword]; ok && val != "" { + metadata.Password = val + } else { + return metadata, errors.New("mysql connect error: missing password") + } + + if val, ok := properties[mysqlHost]; ok && val != "" { + metadata.MysqlHost = val + } else { + return metadata, errors.New("mysql connect error: missing mysqlHost") + } + metadata.WorkIdBits = defalutWorkerBits if val, ok := properties[workerBits]; ok && val != "" { if metadata.WorkIdBits, err = strconv.ParseInt(val, 10, 64); err != nil { @@ -114,54 +129,16 @@ func ParseSnowflakeRingBufferMetadata(properties map[string]string) (RingBufferM return metadata, err } metadata.StartTime = tmp.Unix() - return metadata, nil -} - -type MysqlMetadata struct { - UserName string - Password string - DatabaseName string - TableName string - Db *sql.DB - //ip:port - MysqlHost string -} -func ParseSnowflakeMysqlMetadata(properties map[string]string) (MysqlMetadata, error) { - m := MysqlMetadata{} - m.TableName = defaultTableName - if val, ok := properties[tableName]; ok && val != "" { - m.TableName = val - } - if val, ok := properties[databaseName]; ok && val != "" { - m.DatabaseName = val - } else { - return m, errors.New("mysql connect error: missing database name") - } - if val, ok := properties[userName]; ok && val != "" { - m.UserName = val - } else { - return m, errors.New("mysql connect error: missing username") - } - if val, ok := properties[password]; ok && val != "" { - m.Password = val - } else { - return m, errors.New("mysql connect error: missing password") - } - if val, ok := properties[mysqlHost]; ok && val != "" { - m.MysqlHost = val - } else { - return m, errors.New("mysql connect error: missing mysqlHost") - } - return m, nil + return metadata, nil } -func NewMysqlClient(meta MysqlMetadata) (int64, error) { +func NewMysqlClient(meta SnowflakeMetadata) (int64, error) { var workId int64 //for unit test if meta.Db == nil { - mysql := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=%s&parseTime=true&loc=Local", meta.UserName, meta.Password, meta.MysqlHost, meta.DatabaseName, charset) + mysql := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=%s&parseTime=true&loc=Local", meta.UserName, meta.Password, meta.MysqlHost, meta.DatabaseName, mysqlCharset) db, err := sql.Open("mysql", mysql) if err != nil { return workId, err @@ -190,7 +167,7 @@ func NewMysqlClient(meta MysqlMetadata) (int64, error) { //get id from mysql //host_name = "ip" //port = "timestamp-random number" -func NewWorkId(meta MysqlMetadata) (int64, error) { +func NewWorkId(meta SnowflakeMetadata) (int64, error) { defer meta.Db.Close() var workId int64 @@ -238,6 +215,7 @@ func NewWorkId(meta MysqlMetadata) (int64, error) { } return workId, nil } + func getMysqlPort() string { currentTimeMills := time.Now().Unix() rand.Seed(time.Now().UnixNano()) diff --git a/components/pkg/utils/snowflake/ringbuffer.go b/components/pkg/utils/snowflake/ringbuffer.go deleted file mode 100755 index f4d4c84ff4..0000000000 --- a/components/pkg/utils/snowflake/ringbuffer.go +++ /dev/null @@ -1,197 +0,0 @@ -// -// Copyright 2021 Layotto Authors -// 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 snowflake - -import ( - "errors" - "runtime" - "sync" - "sync/atomic" - - "mosn.io/pkg/log" -) - -const ( - CAN_TAKE_FLAG = 1 - CAN_PUT_FLAG = 0 -) - -//avoid false sharing -type PaddedInt struct { - _ [7]int64 - Value int64 -} - -//there are two ringbuffers, one is to store uid, another is to store flag, flag represents the slot is readable or writable -type RingBuffer struct { - m sync.Mutex - //store uid - slots []int64 - //store flag - flags []PaddedInt - //write pointer, wp is readable, next is writable - wp PaddedInt - //read pointer, rp is writable, next is readable - rp PaddedInt - - //1 + WorkIdBits + TimeBits + SeqBits = 64 - TimeBits int64 - WorkIdBits int64 - SeqBits int64 - - //ringbuffer's size - bufferSize int64 - //when readable slots nums <= bufferSize * PaddingFactor / 100, start padding goroutine - PaddingFactor int64 - - //get id from Mysql at startup - WorkId int64 - //get current timestamp at startup - CurrentTimeStamp int64 - - //whether there is a running padding goroutine - running int32 -} - -func NewRingBuffer(bufferSize int64) *RingBuffer { - p := PaddedInt{} - p.Value = -1 - return &RingBuffer{ - slots: make([]int64, bufferSize), - flags: make([]PaddedInt, bufferSize), - wp: p, - rp: p, - bufferSize: bufferSize, - running: 0, - } -} - -func (r *RingBuffer) Put(uid int64) (bool, error) { - r.m.Lock() - defer r.m.Unlock() - currentWritePointer := r.wp.Value - currentReadPointer := r.rp.Value - if currentReadPointer == -1 { - currentReadPointer = 0 - } - - distance := currentWritePointer - currentReadPointer - //write pointer catches read pointer, ringbuffer is full - if distance == r.bufferSize-1 { - return false, errors.New("ringbuffer is full! Rejected putting buffer") - } - - nextWriteIndex := (currentWritePointer + 1) & (r.bufferSize - 1) - //The flag at this location may not have been updated after reading a uid, so yield the processor to update it - for r.flags[nextWriteIndex].Value != CAN_PUT_FLAG { - runtime.Gosched() - } - - r.slots[nextWriteIndex] = uid - r.flags[nextWriteIndex].Value = CAN_TAKE_FLAG - r.wp.Value++ - return true, nil -} - -//taking uid is a lock free operation to ensure the only padding goroutine can get enough time slices -func (r *RingBuffer) Take() (int64, error) { - var uid int64 - var currentReadPointer int64 - var nextReadPointer int64 - - //atomically update r.rp.value if r.rp.Value != r.wp.Value, otherwise wait until r.rp.Value != r.wp.Value - for { - currentReadPointer = r.rp.Value - nextReadPointer = currentReadPointer - if currentReadPointer < r.wp.Value { - nextReadPointer++ - } else { - continue - } - if atomic.CompareAndSwapInt64(&r.rp.Value, currentReadPointer, nextReadPointer) { - break - } - } - - if r.wp.Value-currentReadPointer < r.bufferSize*r.PaddingFactor/100 { - go r.PaddingRingBuffer() - } - - if currentReadPointer == nextReadPointer { - panic("read pointer is false") - } - - nextReadIndex := nextReadPointer & (r.bufferSize - 1) - //check next slot flag is CAN_TAKE_FLAG - if atomic.LoadInt64(&r.flags[nextReadIndex].Value) != CAN_TAKE_FLAG { - panic("slot is not in can take status") - } - - uid = r.slots[nextReadIndex] - r.flags[nextReadIndex].Value = CAN_PUT_FLAG - return uid, nil -} - -//allocate workid and timestamp for uid -func (r *RingBuffer) Allocator() int64 { - timestampShift := r.SeqBits - workidShift := r.TimeBits + r.SeqBits - - workid := r.WorkId - timestamp := r.CurrentTimeStamp - r.CurrentTimeStamp++ - - var sequence int64 - return timestamp< r.bufferSize*r.PaddingFactor/100 || !atomic.CompareAndSwapInt32(&r.running, 0, 1) { - return false - } - - for { - u := r.Allocator() - if ok, err := r.GenerateUid(u); !ok || err != nil { - log.DefaultLogger.Warnf("%v", err) - break - } - } - - if !atomic.CompareAndSwapInt32(&r.running, 1, 0) { - panic("running num is false") - } - return true -} diff --git a/components/pkg/utils/snowflake/ringbuffer_test.go b/components/pkg/utils/snowflake/ringbuffer_test.go deleted file mode 100644 index 5d4e376b05..0000000000 --- a/components/pkg/utils/snowflake/ringbuffer_test.go +++ /dev/null @@ -1,46 +0,0 @@ -// -// Copyright 2021 Layotto Authors -// 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 snowflake - -import ( - "testing" - "time" - - "github.com/stretchr/testify/assert" -) - -func TestPaddingRingBuffer(t *testing.T) { - rb := NewRingBuffer(65536) - - rb.TimeBits = 28 - rb.WorkIdBits = 22 - rb.SeqBits = 13 - rb.PaddingFactor = 50 - - s := "2022-01-01" - - var tmp time.Time - tmp, err := time.ParseInLocation("2006-01-02", s, time.Local) - assert.NoError(t, err) - startTime := tmp.Unix() - rb.CurrentTimeStamp = time.Now().Unix() - startTime - rb.PaddingRingBuffer() - - var uid int64 - for i := 0; i < 100000; i++ { - uid, err = rb.Take() - assert.NoError(t, err) - assert.NotEqual(t, uid, 0) - } -} diff --git a/components/pkg/utils/snowflake/snowflake_test.go b/components/pkg/utils/snowflake_test.go similarity index 63% rename from components/pkg/utils/snowflake/snowflake_test.go rename to components/pkg/utils/snowflake_test.go index 4a81561be3..debd7a727d 100644 --- a/components/pkg/utils/snowflake/snowflake_test.go +++ b/components/pkg/utils/snowflake_test.go @@ -11,7 +11,7 @@ // 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 snowflake +package utils import ( "database/sql" @@ -21,48 +21,33 @@ import ( "github.com/stretchr/testify/assert" ) -func TestParseSnowflakeRingBufferMetadata(t *testing.T) { +func TestParseSnowflakeMetadata(t *testing.T) { properties := make(map[string]string) - properties["workerBits"] = "1" - properties["timeBits"] = "1" - properties["seqBits"] = "1" - _, err := ParseSnowflakeRingBufferMetadata(properties) - assert.Error(t, err) - - properties["startTime"] = "2022.01.01" - _, err = ParseSnowflakeRingBufferMetadata(properties) + _, err := ParseSnowflakeMetadata(properties) assert.Error(t, err) - properties["boostPower"] = "a" - _, err = ParseSnowflakeRingBufferMetadata(properties) - assert.Error(t, err) - - properties["paddingFactor"] = "a" - _, err = ParseSnowflakeRingBufferMetadata(properties) - assert.Error(t, err) + properties["mysqlHost"] = "localhost:3306" + properties["databaseName"] = "layotto_sequencer_snowflake" + properties["userName"] = "root" + properties["password"] = "123456" + _, err = ParseSnowflakeMetadata(properties) + assert.NoError(t, err) properties["workerBits"] = "a" - _, err = ParseSnowflakeRingBufferMetadata(properties) + _, err = ParseSnowflakeMetadata(properties) assert.Error(t, err) - properties["timeBits"] = "a" - _, err = ParseSnowflakeRingBufferMetadata(properties) - assert.Error(t, err) - - properties["seqBits"] = "a" - _, err = ParseSnowflakeRingBufferMetadata(properties) - assert.Error(t, err) -} - -func TestParseSnowflakeMysqlMetadata(t *testing.T) { - properties := make(map[string]string) - - _, err := ParseSnowflakeMysqlMetadata(properties) + properties["workerBits"] = "" + properties["startTime"] = "2022.01.01" + _, err = ParseSnowflakeMetadata(properties) assert.Error(t, err) - properties["databaseName"] = "layotto_sequence_snowflake" - _, err = ParseSnowflakeMysqlMetadata(properties) + properties["startTime"] = "2022-01-01" + properties["workerBits"] = "1" + properties["timeBits"] = "1" + properties["seqBits"] = "1" + _, err = ParseSnowflakeMetadata(properties) assert.Error(t, err) } @@ -84,7 +69,7 @@ func TestNewMysqlClient(t *testing.T) { mock.ExpectQuery("SELECT ID").WillReturnRows(sqlmock.NewRows([]string{"id"}).AddRow(1)) mock.ExpectCommit() - m := MysqlMetadata{} + m := SnowflakeMetadata{} m.Db = db workId, err := NewMysqlClient(m) assert.NoError(t, err) diff --git a/components/sequencer/snowflake/snowflake_sequencer.go b/components/sequencer/snowflake/snowflake_sequencer.go index 8c5c616356..2532f044cd 100755 --- a/components/sequencer/snowflake/snowflake_sequencer.go +++ b/components/sequencer/snowflake/snowflake_sequencer.go @@ -14,72 +14,99 @@ package snowflake import ( + "context" "database/sql" + "errors" "time" "mosn.io/pkg/log" - "mosn.io/layotto/components/pkg/utils/snowflake" + "mosn.io/layotto/components/pkg/utils" "mosn.io/layotto/components/sequencer" ) type SnowFlakeSequencer struct { - metadata snowflake.SnowflakeMetadata - ringBuffer *snowflake.RingBuffer + metadata *utils.SnowflakeMetadata + ch chan int64 db *sql.DB biggerThan map[string]int64 logger log.ErrorLogger + ctx context.Context + cancel context.CancelFunc } func NewSnowFlakeSequencer(logger log.ErrorLogger) *SnowFlakeSequencer { return &SnowFlakeSequencer{ + ch: make(chan int64, 1000), logger: logger, } } func (s *SnowFlakeSequencer) Init(config sequencer.Configuration) error { - mm, err := snowflake.ParseSnowflakeMysqlMetadata(config.Properties) + mm, err := utils.ParseSnowflakeMetadata(config.Properties) if err != nil { return err } //for unit test mm.Db = s.db - s.metadata.MysqlMetadata = &mm + s.metadata = &mm s.biggerThan = config.BiggerThan + s.ctx, s.cancel = context.WithCancel(context.Background()) var workId int64 - if workId, err = snowflake.NewMysqlClient(*s.metadata.MysqlMetadata); err != nil { + if workId, err = utils.NewMysqlClient(*s.metadata); err != nil { return err } - rm, err := snowflake.ParseSnowflakeRingBufferMetadata(config.Properties) - - var maxSeq int64 = 1 << rm.SeqBits - bufferSize := maxSeq << rm.BoostPower - - s.ringBuffer = snowflake.NewRingBuffer(bufferSize) - - s.ringBuffer.WorkId = workId - s.ringBuffer.CurrentTimeStamp = time.Now().Unix() - rm.StartTime - s.ringBuffer.TimeBits = rm.TimeBits - s.ringBuffer.WorkIdBits = rm.WorkIdBits - s.ringBuffer.SeqBits = rm.SeqBits - s.ringBuffer.PaddingFactor = rm.PaddingFactor - - s.ringBuffer.PaddingRingBuffer() - + timestampShift := mm.SeqBits + workidShift := mm.TimeBits + mm.SeqBits + + currentTimeStamp := time.Now().Unix() - mm.StartTime + + var sequence int64 + startId := workId< Date: Sun, 9 Oct 2022 19:51:31 +0800 Subject: [PATCH 27/45] fix --- components/sequencer/test/main1/main.go | 81 ------------------ components/sequencer/test/main2/main.go | 104 ------------------------ 2 files changed, 185 deletions(-) delete mode 100644 components/sequencer/test/main1/main.go delete mode 100644 components/sequencer/test/main2/main.go diff --git a/components/sequencer/test/main1/main.go b/components/sequencer/test/main1/main.go deleted file mode 100644 index d3d181006f..0000000000 --- a/components/sequencer/test/main1/main.go +++ /dev/null @@ -1,81 +0,0 @@ -package main - -import ( - "fmt" - "time" - - mapset "github.com/deckarep/golang-set" - "mosn.io/layotto/components/sequencer" - "mosn.io/layotto/components/sequencer/snowflake" - "mosn.io/pkg/log" -) - -const key = "resource_xxx" - -var size int = 8000000 - -const ( - defaultMysqlUrl = "localhost:3306" - defaultDatabaseName = "layotto_sequencer" - defaultTableName = "layotto_sequencer_snowflake" - defaultUserName = "root" - defaultPassword = "oooooo" -) - -func main() { - s := snowflake.NewSnowFlakeSequencer(log.DefaultLogger) - cfg := sequencer.Configuration{ - Properties: make(map[string]string), - BiggerThan: make(map[string]int64), - } - cfg.Properties["mysqlHost"] = defaultMysqlUrl - cfg.Properties["databaseName"] = defaultDatabaseName - cfg.Properties["tableName"] = defaultTableName - cfg.Properties["userName"] = defaultUserName - cfg.Properties["password"] = defaultPassword - - // cfg.Properties["boostPower"] = "3" - // cfg.Properties["paddingFactor"] = "50" - cfg.Properties["timeBits"] = "28" - cfg.Properties["workerBits"] = "22" - cfg.Properties["seqBits"] = "13" - cfg.Properties["startTime"] = "2022-01-01" - - t1 := time.Now().UnixNano() / 1e6 - if err := s.Init(cfg); err != nil { - fmt.Println(err) - } - - fmt.Println("start getting") - mset := mapset.NewSet() - - var uid int64 - var ccc int64 - var temp int64 - var i int - var count int - for i = 0; i < size; i++ { - resp, err := s.GetNextId(&sequencer.GetNextIdRequest{ - Key: key, - }) - // mset.Add(resp.NextId) - // if err != nil{ - // count++ - // } - if err == nil { - if temp != 0 && resp.NextId <= temp { - ccc++ - } - mset.Add(resp.NextId) - temp = resp.NextId - count++ - } - // fmt.Printf("%b\n", resp.NextId) - } - // // assert.Equal(t, size, mset.Cardinality()) - fmt.Println(count) - fmt.Println(uid) - fmt.Println(time.Now().UnixNano()/1e6 - t1) - fmt.Println(mset.Cardinality()) - fmt.Println(ccc) -} diff --git a/components/sequencer/test/main2/main.go b/components/sequencer/test/main2/main.go deleted file mode 100644 index bc69b88de1..0000000000 --- a/components/sequencer/test/main2/main.go +++ /dev/null @@ -1,104 +0,0 @@ -package main - -import ( - "fmt" - "runtime" - "sync" - "sync/atomic" - "time" - - mapset "github.com/deckarep/golang-set" - "mosn.io/layotto/components/sequencer" - "mosn.io/layotto/components/sequencer/snowflake" - "mosn.io/pkg/log" -) - -const key = "resource_xxx" - -var size int = 600000 - -const ( - defaultMysqlUrl = "localhost:3306" - defaultDatabaseName = "layotto_sequencer" - defaultTableName = "layotto_sequencer_snowflake" - defaultUserName = "root" - defaultPassword = "oooooo" -) - -func main() { - - s := snowflake.NewSnowFlakeSequencer(log.DefaultLogger) - cfg := sequencer.Configuration{ - Properties: make(map[string]string), - BiggerThan: make(map[string]int64), - } - - cfg.Properties["mysqlHost"] = defaultMysqlUrl - cfg.Properties["databaseName"] = defaultDatabaseName - cfg.Properties["tableName"] = defaultTableName - cfg.Properties["userName"] = defaultUserName - cfg.Properties["password"] = defaultPassword - - cfg.Properties["boostPower"] = "3" - cfg.Properties["paddingFactor"] = "50" - cfg.Properties["timeBits"] = "28" - cfg.Properties["workerBits"] = "22" - cfg.Properties["seqBits"] = "13" - cfg.Properties["startTime"] = "2022-01-01" - - if err := s.Init(cfg); err != nil { - fmt.Println(err) - } - - mset := mapset.NewSet() - - var count int64 - var errCount int - var temp int64 - - var wg sync.WaitGroup - var mu sync.Mutex - - cores := 2 * runtime.NumCPU() - wg.Add(cores) - t1 := time.Now().UnixNano() / 1e6 - for i := 0; i < cores; i++ { - go func() { - for j := 0; j < size; j++ { - mu.Lock() - resp, err := s.GetNextId(&sequencer.GetNextIdRequest{ - Key: key, - }) - // if err != nil{ - // // fmt.Println(err) - // atomic.AddInt64(&count, 1) - // } - // if err == nil { - // mset.Add(resp.NextId) - // } else { - // fmt.Println(err) - // atomic.AddInt64(&count, 1) - // } - - if err == nil { - // fmt.Println(resp.NextId) - mset.Add(resp.NextId) - if temp != 0 && resp.NextId <= temp { - errCount++ - } - temp = resp.NextId - } else { - atomic.AddInt64(&count, 1) - } - mu.Unlock() - } - wg.Done() - }() - } - wg.Wait() - // // assert.Equal(t, size, mset.Cardinality()) - fmt.Println(count) - fmt.Println(time.Now().UnixNano()/1e6 - t1) - fmt.Println(mset.Cardinality()) - fmt.Println(errCount) -} From f3e1f6e70204e75379161ad0bc750c4ee9cd590e Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Sun, 9 Oct 2022 20:16:20 +0800 Subject: [PATCH 28/45] fix --- go.sum | 1 - 1 file changed, 1 deletion(-) diff --git a/go.sum b/go.sum index 2ae70b10ed..68cd4b3655 100644 --- a/go.sum +++ b/go.sum @@ -358,7 +358,6 @@ github.com/dancannon/gorethink v4.0.0+incompatible/go.mod h1:BLvkat9KmZc1efyYwhz github.com/danieljoos/wincred v1.0.2/go.mod h1:SnuYRW9lp1oJrZX/dXJqr0cPK5gYXqx3EJbmjhLdK9U= github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0= github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0= -github.com/dapr/components-contrib v1.5.1-rc.1/go.mod h1:k40RvOMnDmJMSSbWZ10ajjWJ9pEuq4Z5eKxCa/yrAe8= github.com/dapr/components-contrib v1.5.2 h1:zMP0pvWjpu4/AVTQzlWnixhlJUg9S1op8QIuq4DMSus= github.com/dapr/components-contrib v1.5.2/go.mod h1:k40RvOMnDmJMSSbWZ10ajjWJ9pEuq4Z5eKxCa/yrAe8= github.com/dapr/kit v0.0.2-0.20210614175626-b9074b64d233 h1:M0dWIG8kUxEFU57IqTWeqptNqlBsfosFgsA5Ov7rJ8g= From a9e1d6dedb482d89b752312124c1d12612b1e6eb Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Sun, 9 Oct 2022 21:18:02 +0800 Subject: [PATCH 29/45] fix --- components/go.mod | 22 ++------------- components/go.sum | 27 +++++++++++++++++-- components/pkg/utils/snowflake.go | 4 +-- .../snowflake/snowflake_sequencer.go | 6 ++--- go.sum | 4 +-- 5 files changed, 33 insertions(+), 30 deletions(-) diff --git a/components/go.mod b/components/go.mod index 9328b94b07..da4504d0f8 100644 --- a/components/go.mod +++ b/components/go.mod @@ -8,51 +8,33 @@ require ( github.com/aliyun/aliyun-oss-go-sdk v2.2.0+incompatible github.com/apache/dubbo-go-hessian2 v1.10.2 github.com/apolloconfig/agollo/v4 v4.2.0 - github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878 // indirect github.com/aws/aws-sdk-go-v2 v1.16.4 github.com/aws/aws-sdk-go-v2/config v1.15.9 github.com/aws/aws-sdk-go-v2/credentials v1.12.4 github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.14 github.com/aws/aws-sdk-go-v2/service/s3 v1.26.10 - github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f // indirect - github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f // indirect - github.com/deckarep/golang-set v1.8.0 + github.com/dapr/components-contrib v1.5.2 github.com/go-redis/redis/v8 v8.8.0 - github.com/go-sql-driver/mysql v1.6.0 + github.com/go-sql-driver/mysql v1.5.0 github.com/go-zookeeper/zk v1.0.2 github.com/golang/mock v1.6.0 github.com/google/uuid v1.3.0 github.com/hashicorp/consul/api v1.3.0 - github.com/hashicorp/go-msgpack v1.1.5 // indirect - github.com/hashicorp/golang-lru v0.5.4 // indirect github.com/jarcoal/httpmock v1.2.0 github.com/jinzhu/copier v0.3.6-0.20220506024824-3e39b055319a - github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect - github.com/miekg/dns v1.1.35 // indirect github.com/minio/minio-go/v7 v7.0.15 - github.com/mitchellh/mapstructure v1.4.1 // indirect - github.com/nxadm/tail v1.4.8 // indirect github.com/pkg/errors v0.9.1 github.com/qiniu/go-sdk/v7 v7.11.1 - github.com/sergi/go-diff v1.2.0 // indirect - github.com/spf13/afero v1.2.2 // indirect - github.com/spf13/cast v1.3.1 // indirect github.com/stretchr/testify v1.7.0 github.com/tencentyun/cos-go-sdk-v5 v0.7.33 - github.com/tidwall/pretty v1.2.0 // indirect github.com/valyala/fasthttp v1.26.0 go.beyondstorage.io/services/hdfs v0.3.0 go.beyondstorage.io/v5 v5.0.0 - go.etcd.io/etcd v0.5.0-alpha.5.0.20200910180754-dd1b699fc489 // indirect go.etcd.io/etcd/api/v3 v3.5.0 go.etcd.io/etcd/client/v3 v3.5.0 go.etcd.io/etcd/server/v3 v3.5.0 go.mongodb.org/mongo-driver v1.8.0 go.uber.org/atomic v1.8.0 - go.uber.org/multierr v1.7.0 // indirect - go.uber.org/zap v1.18.1 // indirect - golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect - golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93 // indirect google.golang.org/grpc v1.38.0 mosn.io/api v1.1.0 mosn.io/mosn v1.1.0 diff --git a/components/go.sum b/components/go.sum index a2da09a937..ccd1e66826 100644 --- a/components/go.sum +++ b/components/go.sum @@ -92,6 +92,8 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= +github.com/DataDog/zstd v1.3.6-0.20190409195224-796139022798/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= +github.com/DataDog/zstd v1.4.6-0.20210211175136-c6db21d202f4/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/HdrHistogram/hdrhistogram-go v1.0.1/go.mod h1:BWJ+nMSHY3L41Zj7CA3uXnloDp7xxV0YvstAE7nKTaM= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= @@ -215,6 +217,7 @@ github.com/aws/smithy-go v1.11.2/go.mod h1:3xHYmszWVx2c0kIwQeEVf9uSm4fYZt67FBJnw github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f h1:ZNv7On9kyUzm7fvRZumSyy/IUiSC7AzL0I1jKKtwooA= github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f/go.mod h1:AuiFmCCPBSrqvVMvuqFuk0qogytodnVFVSN5CeJB8Gc= +github.com/beefsack/go-rate v0.0.0-20180408011153-efa7637bb9b6/go.mod h1:6YNgTHLutezwnBvyneBbwvB8C82y3dcoOj5EQJIdGXA= github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= @@ -253,6 +256,7 @@ github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/cinience/go_rocketmq v0.0.2/go.mod h1:2YNY7emT546dcFpMEWLesmAEi4ndW7+tX5VfNf1Zsgs= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= @@ -441,9 +445,8 @@ github.com/go-redis/redis/v8 v8.8.0/go.mod h1:F7resOH5Kdug49Otu24RjHWwgK7u9AmtqW github.com/go-resty/resty/v2 v2.6.0/go.mod h1:PwvJS6hvaPkjtjNg9ph+VrSD92bi5Zq73w/BIH7cC3Q= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= +github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= -github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= -github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:56xuuqnHyryaerycW3BfssRdxQstACi0Epw/yC5E2xM= @@ -635,6 +638,7 @@ github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39 github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-msgpack v1.1.5 h1:9byZdVjKTe5mce63pRVNP1L7UAmdHOTEMGehn6KvJWs= github.com/hashicorp/go-msgpack v1.1.5/go.mod h1:gWVc3sv/wbDmR3rQsj1CAktEZzoz1YNK9NfGLXJ69/4= github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o= @@ -882,6 +886,8 @@ github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3N github.com/miekg/dns v1.1.25/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.35 h1:oTfOaDH+mZkdcgdIjH6yBajRGtIwcwcaR+rt23ZSrJs= github.com/miekg/dns v1.1.35/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= +github.com/minio/highwayhash v1.0.0/go.mod h1:xQboMTeM9nY9v/LlAOxFctujiv5+Aq2hR5dxBpaMbdc= +github.com/minio/highwayhash v1.0.1/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= github.com/minio/md5-simd v1.1.0 h1:QPfiOqlZH+Cj9teu0t9b1nTBfPbyTl16Of5MeuShdK4= github.com/minio/md5-simd v1.1.0/go.mod h1:XpBqgZULrMYD3R+M28PcmP0CkI7PEMzB3U77ZrKZ0Gw= github.com/minio/minio-go/v7 v7.0.15 h1:r9/NhjJ+nXYrIYvbObhvc1wPj3YH1iDpJzz61uRKLyY= @@ -1008,6 +1014,7 @@ github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIw github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pborman/getopt v0.0.0-20180729010549-6fdd0a2c7117/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= @@ -1108,6 +1115,8 @@ github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/sendgrid/rest v2.6.3+incompatible/go.mod h1:kXX7q3jZtJXK5c5qK83bSGMdV6tsOE70KbHoqJls4lE= +github.com/sendgrid/sendgrid-go v3.5.0+incompatible/go.mod h1:QRQt+LX/NmgVEvmdRw0VT/QgUn499+iza2FnDca9fg8= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= @@ -1146,6 +1155,7 @@ github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTd github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cobra v0.0.0-20181021141114-fe5e611709b0/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= @@ -1186,9 +1196,17 @@ github.com/tencentyun/cos-go-sdk-v5 v0.7.33/go.mod h1:4E4+bQ2gBVJcgEC9Cufwylio4m github.com/testcontainers/testcontainers-go v0.9.0/go.mod h1:b22BFXhRbg4PJmeMVWh6ftqjyZHgiIl3w274e9r3C2E= github.com/tevid/gohamcrest v1.1.1 h1:ou+xSqlIw1xfGTg1uq1nif/htZ2S3EzRqLm2BP+tYU0= github.com/tevid/gohamcrest v1.1.1/go.mod h1:3UvtWlqm8j5JbwYZh80D/PVBt0mJ1eJiYgZMibh0H/k= +github.com/tidwall/gjson v1.2.1/go.mod h1:c/nTNbUr0E0OrXEhq1pwa8iEgc2DOt4ZZqAt1HtCkPA= +github.com/tidwall/gjson v1.8.0/go.mod h1:5/xDoumyyDNerp2U36lyolv46b3uF/9Bu6OfyQ9GImk= +github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E= +github.com/tidwall/match v1.0.3/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= +github.com/tidwall/pretty v0.0.0-20190325153808-1166b9ac2b65/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= +github.com/tidwall/pretty v1.1.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tklauser/go-sysconf v0.3.6/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI= +github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20200427203606-3cfed13b9966/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= @@ -1350,6 +1368,7 @@ go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= go.uber.org/zap v1.18.1 h1:CSUJ2mjFszzEWt4CdKISEuChVIXGBn3lAPwkRGyVrc4= go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= +goji.io v2.0.2+incompatible/go.mod h1:sbqFwrtqZACxLBTQcdgVjFh54yGVCvwq8+w49MVMMIk= golang.org/x/arch v0.0.0-20180920145803-b19384d3c130/go.mod h1:cYlCBUl1MsqxdiKgmc4uh7TxZfWSFLOGSRR090WDxt8= golang.org/x/arch v0.0.0-20200826200359-b19915210f00 h1:cfd5G6xu8iZTFmjBYVemyBmE/sTf0A3vpE3BmoOuLCI= golang.org/x/arch v0.0.0-20200826200359-b19915210f00/go.mod h1:flIaEI6LNU6xOCD5PaJvn9wGP0agmIOqjrtsKGRguv4= @@ -1485,6 +1504,7 @@ golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93 h1:alLDrZkL34Y2bnGHfvC1CYBRBXCXgx8AC2vY4MRtYX4= golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1626,6 +1646,9 @@ golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190424220101-1e8e1cfdf96b/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= diff --git a/components/pkg/utils/snowflake.go b/components/pkg/utils/snowflake.go index ac2f8620f3..9fb2e32158 100755 --- a/components/pkg/utils/snowflake.go +++ b/components/pkg/utils/snowflake.go @@ -47,13 +47,13 @@ const ( type SnowflakeMetadata struct { // MysqlMetadata + //ip:port + MysqlHost string UserName string Password string DatabaseName string TableName string Db *sql.DB - //ip:port - MysqlHost string WorkIdBits int64 TimeBits int64 diff --git a/components/sequencer/snowflake/snowflake_sequencer.go b/components/sequencer/snowflake/snowflake_sequencer.go index 2532f044cd..5f7d6ab13b 100755 --- a/components/sequencer/snowflake/snowflake_sequencer.go +++ b/components/sequencer/snowflake/snowflake_sequencer.go @@ -26,7 +26,7 @@ import ( ) type SnowFlakeSequencer struct { - metadata *utils.SnowflakeMetadata + metadata utils.SnowflakeMetadata ch chan int64 db *sql.DB biggerThan map[string]int64 @@ -50,12 +50,12 @@ func (s *SnowFlakeSequencer) Init(config sequencer.Configuration) error { //for unit test mm.Db = s.db - s.metadata = &mm + s.metadata = mm s.biggerThan = config.BiggerThan s.ctx, s.cancel = context.WithCancel(context.Background()) var workId int64 - if workId, err = utils.NewMysqlClient(*s.metadata); err != nil { + if workId, err = utils.NewMysqlClient(s.metadata); err != nil { return err } diff --git a/go.sum b/go.sum index 68cd4b3655..8e233a519b 100644 --- a/go.sum +++ b/go.sum @@ -372,7 +372,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= -github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= github.com/deepmap/oapi-codegen v1.3.6/go.mod h1:aBozjEveG+33xPiP55Iw/XbVkhtZHEGLq3nxlX0+hfU= github.com/deepmap/oapi-codegen v1.8.1/go.mod h1:YLgSKSDv/bZQB7N4ws6luhozi3cEdRktEqrX88CvjIw= github.com/denisenkom/go-mssqldb v0.0.0-20190707035753-2be1aa521ff4/go.mod h1:zAg7JM8CkOJ43xKXIj7eRO9kmWm/TW578qo+oDO6tuM= @@ -532,9 +531,8 @@ github.com/go-resty/resty/v2 v2.6.0 h1:joIR5PNLM2EFqqESUjCMGXrWmXNHEU9CEiK813oKY github.com/go-resty/resty/v2 v2.6.0/go.mod h1:PwvJS6hvaPkjtjNg9ph+VrSD92bi5Zq73w/BIH7cC3Q= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= +github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= -github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= -github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:56xuuqnHyryaerycW3BfssRdxQstACi0Epw/yC5E2xM= From 2cb3f0a7962ad50558c73a89fe40f93d6b52fc0a Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Sun, 9 Oct 2022 22:00:43 +0800 Subject: [PATCH 30/45] fix --- components/pkg/utils/snowflake.go | 70 +++++++++++-------- components/pkg/utils/snowflake_test.go | 2 +- .../snowflake/snowflake_sequencer.go | 14 ++-- 3 files changed, 50 insertions(+), 36 deletions(-) diff --git a/components/pkg/utils/snowflake.go b/components/pkg/utils/snowflake.go index 9fb2e32158..3715af0fac 100755 --- a/components/pkg/utils/snowflake.go +++ b/components/pkg/utils/snowflake.go @@ -46,7 +46,17 @@ const ( ) type SnowflakeMetadata struct { - // MysqlMetadata + MysqlMetadata *SnowflakeMysqlMetadata + + WorkerBits int64 + TimeBits int64 + SeqBits int64 + StartTime int64 + WorkId int64 + LogInfo bool +} + +type SnowflakeMysqlMetadata struct { //ip:port MysqlHost string UserName string @@ -54,51 +64,55 @@ type SnowflakeMetadata struct { DatabaseName string TableName string Db *sql.DB - - WorkIdBits int64 - TimeBits int64 - SeqBits int64 - StartTime int64 - WorkId int64 - LogInfo bool } -func ParseSnowflakeMetadata(properties map[string]string) (SnowflakeMetadata, error) { - metadata := SnowflakeMetadata{} - var err error +func ParseSnowflakeMysqlMetadata(properties map[string]string) (SnowflakeMysqlMetadata, error) { + mm := SnowflakeMysqlMetadata{} - metadata.TableName = defaultTableName + mm.TableName = defaultTableName if val, ok := properties[mysqlTableName]; ok && val != "" { - metadata.TableName = val + mm.TableName = val + } + + if val, ok := properties[mysqlHost]; ok && val != "" { + mm.MysqlHost = val + } else { + return mm, errors.New("mysql connect error: missing mysqlHost") } if val, ok := properties[mysqlDatabaseName]; ok && val != "" { - metadata.DatabaseName = val + mm.DatabaseName = val } else { - return metadata, errors.New("mysql connect error: missing database name") + return mm, errors.New("mysql connect error: missing database name") } if val, ok := properties[mysqlUserName]; ok && val != "" { - metadata.UserName = val + mm.UserName = val } else { - return metadata, errors.New("mysql connect error: missing username") + return mm, errors.New("mysql connect error: missing username") } if val, ok := properties[mysqlPassword]; ok && val != "" { - metadata.Password = val + mm.Password = val } else { - return metadata, errors.New("mysql connect error: missing password") + return mm, errors.New("mysql connect error: missing password") } + return mm, nil +} - if val, ok := properties[mysqlHost]; ok && val != "" { - metadata.MysqlHost = val - } else { - return metadata, errors.New("mysql connect error: missing mysqlHost") +func ParseSnowflakeMetadata(properties map[string]string) (SnowflakeMetadata, error) { + metadata := SnowflakeMetadata{} + var err error + + mm, err := ParseSnowflakeMysqlMetadata(properties) + if err != nil { + return metadata, err } + metadata.MysqlMetadata = &mm - metadata.WorkIdBits = defalutWorkerBits + metadata.WorkerBits = defalutWorkerBits if val, ok := properties[workerBits]; ok && val != "" { - if metadata.WorkIdBits, err = strconv.ParseInt(val, 10, 64); err != nil { + if metadata.WorkerBits, err = strconv.ParseInt(val, 10, 64); err != nil { return metadata, err } } @@ -115,7 +129,7 @@ func ParseSnowflakeMetadata(properties map[string]string) (SnowflakeMetadata, er } } - if metadata.TimeBits+metadata.WorkIdBits+metadata.SeqBits+1 != 64 { + if metadata.TimeBits+metadata.WorkerBits+metadata.SeqBits+1 != 64 { return metadata, errors.New("not enough 64bits") } @@ -133,7 +147,7 @@ func ParseSnowflakeMetadata(properties map[string]string) (SnowflakeMetadata, er return metadata, nil } -func NewMysqlClient(meta SnowflakeMetadata) (int64, error) { +func NewMysqlClient(meta SnowflakeMysqlMetadata) (int64, error) { var workId int64 //for unit test @@ -167,7 +181,7 @@ func NewMysqlClient(meta SnowflakeMetadata) (int64, error) { //get id from mysql //host_name = "ip" //port = "timestamp-random number" -func NewWorkId(meta SnowflakeMetadata) (int64, error) { +func NewWorkId(meta SnowflakeMysqlMetadata) (int64, error) { defer meta.Db.Close() var workId int64 diff --git a/components/pkg/utils/snowflake_test.go b/components/pkg/utils/snowflake_test.go index debd7a727d..7f43bcd4e5 100644 --- a/components/pkg/utils/snowflake_test.go +++ b/components/pkg/utils/snowflake_test.go @@ -69,7 +69,7 @@ func TestNewMysqlClient(t *testing.T) { mock.ExpectQuery("SELECT ID").WillReturnRows(sqlmock.NewRows([]string{"id"}).AddRow(1)) mock.ExpectCommit() - m := SnowflakeMetadata{} + m := SnowflakeMysqlMetadata{} m.Db = db workId, err := NewMysqlClient(m) assert.NoError(t, err) diff --git a/components/sequencer/snowflake/snowflake_sequencer.go b/components/sequencer/snowflake/snowflake_sequencer.go index 5f7d6ab13b..6f523588fe 100755 --- a/components/sequencer/snowflake/snowflake_sequencer.go +++ b/components/sequencer/snowflake/snowflake_sequencer.go @@ -43,26 +43,26 @@ func NewSnowFlakeSequencer(logger log.ErrorLogger) *SnowFlakeSequencer { } func (s *SnowFlakeSequencer) Init(config sequencer.Configuration) error { - mm, err := utils.ParseSnowflakeMetadata(config.Properties) + sm, err := utils.ParseSnowflakeMetadata(config.Properties) if err != nil { return err } //for unit test - mm.Db = s.db + sm.MysqlMetadata.Db = s.db - s.metadata = mm + s.metadata = sm s.biggerThan = config.BiggerThan s.ctx, s.cancel = context.WithCancel(context.Background()) var workId int64 - if workId, err = utils.NewMysqlClient(s.metadata); err != nil { + if workId, err = utils.NewMysqlClient(*s.metadata.MysqlMetadata); err != nil { return err } - timestampShift := mm.SeqBits - workidShift := mm.TimeBits + mm.SeqBits + timestampShift := sm.SeqBits + workidShift := sm.TimeBits + sm.SeqBits - currentTimeStamp := time.Now().Unix() - mm.StartTime + currentTimeStamp := time.Now().Unix() - sm.StartTime var sequence int64 startId := workId< Date: Sun, 9 Oct 2022 22:10:31 +0800 Subject: [PATCH 31/45] fix --- components/sequencer/snowflake/snowflake_sequencer.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/components/sequencer/snowflake/snowflake_sequencer.go b/components/sequencer/snowflake/snowflake_sequencer.go index 6f523588fe..3129c32e9b 100755 --- a/components/sequencer/snowflake/snowflake_sequencer.go +++ b/components/sequencer/snowflake/snowflake_sequencer.go @@ -86,12 +86,11 @@ func (s *SnowFlakeSequencer) Init(config sequencer.Configuration) error { if len(s.ch) == 0 { close(s.ch) return - } else { - continue } + } else { + s.ch <- id + id++ } - s.ch <- id - id++ } } }(s.ctx, startId, maxId) From 9bc32a06e13fad36b584f0c655082e96634ac581 Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Sun, 9 Oct 2022 23:36:15 +0800 Subject: [PATCH 32/45] fix --- components/sequencer/snowflake/snowflake_sequencer.go | 9 +++++++-- docs/zh/component_specs/sequencer/snowflake.md | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/components/sequencer/snowflake/snowflake_sequencer.go b/components/sequencer/snowflake/snowflake_sequencer.go index 3129c32e9b..1a07983bc1 100755 --- a/components/sequencer/snowflake/snowflake_sequencer.go +++ b/components/sequencer/snowflake/snowflake_sequencer.go @@ -100,8 +100,13 @@ func (s *SnowFlakeSequencer) Init(config sequencer.Configuration) error { func (s *SnowFlakeSequencer) GetNextId(req *sequencer.GetNextIdRequest) (*sequencer.GetNextIdResponse, error) { var id int64 var ok bool - if id, ok = <-s.ch; !ok { - return nil, errors.New("timeBits has been used up, please adjust the start time") + select { + case id, ok = <-s.ch: + if !ok { + return nil, errors.New("timeBits has been used up, please adjust the start time") + } + case <-time.After(10 * time.Second): + return nil, errors.New("time out, please request again") } return &sequencer.GetNextIdResponse{ diff --git a/docs/zh/component_specs/sequencer/snowflake.md b/docs/zh/component_specs/sequencer/snowflake.md index 97e077c619..40fd18a17b 100644 --- a/docs/zh/component_specs/sequencer/snowflake.md +++ b/docs/zh/component_specs/sequencer/snowflake.md @@ -2,7 +2,7 @@ ## 配置项说明 -示例:configs/runtime_config.json +示例:configs/config_snowflake.json | 字段 | 必填 | 说明 | | ------------- | ---- | ------------------------------------------------------------ | From 73c2046fa42417b5cf42ddf3a0fa969b78c29618 Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Mon, 10 Oct 2022 16:52:37 +0800 Subject: [PATCH 33/45] fix --- cmd/layotto_multiple_api/main.go | 4 ++++ cmd/layotto_without_xds/main.go | 4 ++++ components/pkg/utils/snowflake.go | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/layotto_multiple_api/main.go b/cmd/layotto_multiple_api/main.go index e0cd704f53..4e6d985a7c 100644 --- a/cmd/layotto_multiple_api/main.go +++ b/cmd/layotto_multiple_api/main.go @@ -143,6 +143,7 @@ import ( sequencer_mongo "mosn.io/layotto/components/sequencer/mongo" sequencer_mysql "mosn.io/layotto/components/sequencer/mysql" sequencer_redis "mosn.io/layotto/components/sequencer/redis" + sequencer_snowflake "mosn.io/layotto/components/sequencer/snowflake" sequencer_zookeeper "mosn.io/layotto/components/sequencer/zookeeper" // Actuator @@ -456,6 +457,9 @@ func NewRuntimeGrpcServer(data json.RawMessage, opts ...grpc.ServerOption) (mgrp runtime_sequencer.NewFactory("mysql", func() sequencer.Store { return sequencer_mysql.NewMySQLSequencer(log.DefaultLogger) }), + runtime_sequencer.NewFactory("snowflake", func() sequencer.Store { + return sequencer_snowflake.NewSnowFlakeSequencer(log.DefaultLogger) + }), ), // secretstores runtime.WithSecretStoresFactory( diff --git a/cmd/layotto_without_xds/main.go b/cmd/layotto_without_xds/main.go index 284aa49c62..6ffd40fe7e 100644 --- a/cmd/layotto_without_xds/main.go +++ b/cmd/layotto_without_xds/main.go @@ -132,6 +132,7 @@ import ( sequencer_inmemory "mosn.io/layotto/components/sequencer/in-memory" sequencer_mongo "mosn.io/layotto/components/sequencer/mongo" sequencer_redis "mosn.io/layotto/components/sequencer/redis" + sequencer_snowflake "mosn.io/layotto/components/sequencer/snowflake" sequencer_zookeeper "mosn.io/layotto/components/sequencer/zookeeper" // Actuator @@ -426,6 +427,9 @@ func NewRuntimeGrpcServer(data json.RawMessage, opts ...grpc.ServerOption) (mgrp runtime_sequencer.NewFactory("in-memory", func() sequencer.Store { return sequencer_inmemory.NewInMemorySequencer() }), + runtime_sequencer.NewFactory("snowflake", func() sequencer.Store { + return sequencer_snowflake.NewSnowFlakeSequencer(log.DefaultLogger) + }), ), // secretstores runtime.WithSecretStoresFactory( diff --git a/components/pkg/utils/snowflake.go b/components/pkg/utils/snowflake.go index 3715af0fac..98d8da5979 100755 --- a/components/pkg/utils/snowflake.go +++ b/components/pkg/utils/snowflake.go @@ -167,7 +167,7 @@ func NewMysqlClient(meta SnowflakeMysqlMetadata) (int64, error) { ID BIGINT NOT NULL AUTO_INCREMENT COMMENT 'auto increment id', HOST_NAME VARCHAR(64) NOT NULL COMMENT 'host name', PORT VARCHAR(64) NOT NULL COMMENT 'port', - CREATED TIMESTAMP NOT NULL COMMENT 'created time', + CREATED TIMESTAMP NOT NULL COMMENT 'created time', PRIMARY KEY(ID) )`, meta.TableName) if _, err = meta.Db.Exec(createTable); err != nil { From 68274b135889e39c21d7d812939074c29395ed45 Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Mon, 10 Oct 2022 17:26:16 +0800 Subject: [PATCH 34/45] fix --- docs/_sidebar.md | 1 + docs/zh/_sidebar.md | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/_sidebar.md b/docs/_sidebar.md index c6e50fe91a..b32dfd978c 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -81,6 +81,7 @@ - [Zookeeper](en/component_specs/sequencer/zookeeper.md) - [MongoDB](en/component_specs/sequencer/mongo.md) - [Mysql](en/component_specs/sequencer/mysql.md) + - [Snowflake](en/component_specs/sequencer/snowflake.md) - [Secret Store](en/component_specs/secret/common.md) - [How to deploy and upgrade Layotto](en/operation/) - Design documents diff --git a/docs/zh/_sidebar.md b/docs/zh/_sidebar.md index 158d9aeea7..a50ca7aaed 100644 --- a/docs/zh/_sidebar.md +++ b/docs/zh/_sidebar.md @@ -87,6 +87,7 @@ - [Zookeeper](zh/component_specs/sequencer/zookeeper.md) - [MongoDB](zh/component_specs/sequencer/mongo.md) - [Mysql](zh/component_specs/sequencer/mysql.md) + - [Snowflake](zh/component_specs/sequencer/snowflake.md) - [Secret Store](zh/component_specs/secret/common.md) - [自定义组件](zh/component_specs/custom/common.md) - [如何部署、升级 Layotto](zh/operation/) From 0c26f5d49ce3b4defb663f2a2bb478fb6a37d55b Mon Sep 17 00:00:00 2001 From: seeflood Date: Tue, 11 Oct 2022 16:31:17 +0800 Subject: [PATCH 35/45] upload image to cdn Signed-off-by: seeflood --- docs/en/component_specs/sequencer/snowflake.md | 2 +- docs/img/sequencer/snowflake/snowflake_id.jpg | Bin 32821 -> 0 bytes docs/zh/component_specs/sequencer/snowflake.md | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) delete mode 100755 docs/img/sequencer/snowflake/snowflake_id.jpg diff --git a/docs/en/component_specs/sequencer/snowflake.md b/docs/en/component_specs/sequencer/snowflake.md index 77d2724032..555a06dea1 100644 --- a/docs/en/component_specs/sequencer/snowflake.md +++ b/docs/en/component_specs/sequencer/snowflake.md @@ -20,7 +20,7 @@ Example: configs/config_snowflake.json The overall design of the id generated by the snowflake algorithm is as follows: -![img.jpg](../../../img/sequencer/snowflake/snowflake_id.jpg) +![img.jpg](https://www.gitlink.org.cn/api/attachments/397699) ## How to start mysql diff --git a/docs/img/sequencer/snowflake/snowflake_id.jpg b/docs/img/sequencer/snowflake/snowflake_id.jpg deleted file mode 100755 index e25ebfcb56be23433c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_~`}A`^{e15JdKN&u zzHgtY`60LX%ecnV0}%v_dHe0nlR&@@-wOH7e+V39-}Sxz6RQ<1${knt;gw1SI_=OB z%i@r0Pp`w?JGSyqhWhqGxChk6dsw#!SSw=3f?2v=1fO1m!4?Fem`nM?mJxTsM zLGcGs@jt~WNl?MC069Ro(yTYpG|GSjy8Fk(UqXw< z`rUPJAb%2o89LCPtNPz_uY?<6XWqtGD-LEF`@@9DFcJm} Date: Thu, 13 Oct 2022 12:46:00 +0800 Subject: [PATCH 36/45] fix --- components/pkg/utils/snowflake.go | 90 +++++++--- components/pkg/utils/snowflake_test.go | 14 +- .../snowflake/snowflake_sequencer.go | 167 ++++++++++++------ .../snowflake/snowflake_sequencer_test.go | 30 ++-- .../en/component_specs/sequencer/snowflake.md | 4 +- .../zh/component_specs/sequencer/snowflake.md | 4 +- 6 files changed, 220 insertions(+), 89 deletions(-) diff --git a/components/pkg/utils/snowflake.go b/components/pkg/utils/snowflake.go index 98d8da5979..6ef89e31f1 100755 --- a/components/pkg/utils/snowflake.go +++ b/components/pkg/utils/snowflake.go @@ -30,6 +30,7 @@ const ( mysqlHost = "mysqlHost" mysqlDatabaseName = "databaseName" mysqlTableName = "tableName" + mysqlKeyTableName = "keyTableName" mysqlUserName = "userName" mysqlPassword = "password" mysqlCharset = "utf8" @@ -37,23 +38,32 @@ const ( workerBits = "workerBits" seqBits = "seqBits" startTime = "startTime" + reqTimeout = "reqTimeout" + keyTimeout = "keyTimeout" defaultMysqlTableName = "layotto_sequencer_snowflake" - defalutTimeBits = 28 - defalutWorkerBits = 22 - defalutSeqBits = 13 - defalutStartTime = "2022-01-01" + defaultKeyTableName = "layotto_sequencer_snowflake_key" + defaultTimeBits = 28 + defaultWorkerBits = 22 + defaultSeqBits = 13 + defaultStartTime = "2022-01-01" + defaultReqTimeout = 500 * time.Millisecond + defaultKeyTimeout = 24 * time.Hour ) type SnowflakeMetadata struct { - MysqlMetadata *SnowflakeMysqlMetadata - - WorkerBits int64 - TimeBits int64 - SeqBits int64 - StartTime int64 - WorkId int64 - LogInfo bool + MysqlMetadata SnowflakeMysqlMetadata + + WorkerBits int64 + TimeBits int64 + SeqBits int64 + WorkidShift int64 + TimestampShift int64 + StartTime int64 + WorkId int64 + ReqTimeout time.Duration + KeyTimeout time.Duration + LogInfo bool } type SnowflakeMysqlMetadata struct { @@ -63,6 +73,7 @@ type SnowflakeMysqlMetadata struct { Password string DatabaseName string TableName string + KeyTableName string Db *sql.DB } @@ -74,6 +85,11 @@ func ParseSnowflakeMysqlMetadata(properties map[string]string) (SnowflakeMysqlMe mm.TableName = val } + mm.KeyTableName = defaultKeyTableName + if val, ok := properties[mysqlKeyTableName]; ok && val != "" { + mm.KeyTableName = val + } + if val, ok := properties[mysqlHost]; ok && val != "" { mm.MysqlHost = val } else { @@ -108,21 +124,21 @@ func ParseSnowflakeMetadata(properties map[string]string) (SnowflakeMetadata, er if err != nil { return metadata, err } - metadata.MysqlMetadata = &mm + metadata.MysqlMetadata = mm - metadata.WorkerBits = defalutWorkerBits + metadata.WorkerBits = defaultWorkerBits if val, ok := properties[workerBits]; ok && val != "" { if metadata.WorkerBits, err = strconv.ParseInt(val, 10, 64); err != nil { return metadata, err } } - metadata.TimeBits = defalutTimeBits + metadata.TimeBits = defaultTimeBits if val, ok := properties[timeBits]; ok && val != "" { if metadata.TimeBits, err = strconv.ParseInt(val, 10, 64); err != nil { return metadata, err } } - metadata.SeqBits = defalutSeqBits + metadata.SeqBits = defaultSeqBits if val, ok := properties[seqBits]; ok && val != "" { if metadata.SeqBits, err = strconv.ParseInt(val, 10, 64); err != nil { return metadata, err @@ -133,21 +149,41 @@ func ParseSnowflakeMetadata(properties map[string]string) (SnowflakeMetadata, er return metadata, errors.New("not enough 64bits") } - s := defalutStartTime + s := defaultStartTime if val, ok := properties[startTime]; ok && val != "" { s = val } - var tmp time.Time if tmp, err = time.ParseInLocation("2006-01-02", s, time.Local); err != nil { return metadata, err } metadata.StartTime = tmp.Unix() + metadata.ReqTimeout = defaultReqTimeout + if val, ok := properties[reqTimeout]; ok && val != "" { + parsedVal, err := strconv.Atoi(val) + if err != nil { + return metadata, err + } + metadata.ReqTimeout = time.Duration(parsedVal) * time.Millisecond + } + + metadata.KeyTimeout = defaultKeyTimeout + if val, ok := properties[keyTimeout]; ok && val != "" { + parsedVal, err := strconv.Atoi(val) + if err != nil { + return metadata, err + } + metadata.KeyTimeout = time.Duration(parsedVal) * time.Hour + } + + metadata.TimestampShift = metadata.WorkerBits + metadata.SeqBits + metadata.WorkidShift = metadata.SeqBits + return metadata, nil } -func NewMysqlClient(meta SnowflakeMysqlMetadata) (int64, error) { +func NewMysqlClient(meta *SnowflakeMysqlMetadata) (int64, error) { var workId int64 //for unit test @@ -174,7 +210,19 @@ func NewMysqlClient(meta SnowflakeMysqlMetadata) (int64, error) { return workId, err } - workId, err = NewWorkId(meta) + createKeyTable := fmt.Sprintf( + `CREATE TABLE IF NOT EXISTS %s + ( + SEQUENCER_KEY VARCHAR(64) NOT NULL COMMENT 'sequencer key', + WORKER_ID VARCHAR(64) NOT NULL COMMENT 'worker id', + TIMESTAMP VARCHAR(64) NOT NULL COMMENT 'timestamp', + UNIQUE INDEX (SEQUENCER_KEY) + )`, meta.KeyTableName) + if _, err = meta.Db.Exec(createKeyTable); err != nil { + return workId, err + } + + workId, err = NewWorkId(*meta) return workId, err } @@ -182,8 +230,6 @@ func NewMysqlClient(meta SnowflakeMysqlMetadata) (int64, error) { //host_name = "ip" //port = "timestamp-random number" func NewWorkId(meta SnowflakeMysqlMetadata) (int64, error) { - defer meta.Db.Close() - var workId int64 ip, err := getIP() stringIp := ip.String() diff --git a/components/pkg/utils/snowflake_test.go b/components/pkg/utils/snowflake_test.go index 7f43bcd4e5..14398c5eeb 100644 --- a/components/pkg/utils/snowflake_test.go +++ b/components/pkg/utils/snowflake_test.go @@ -34,21 +34,27 @@ func TestParseSnowflakeMetadata(t *testing.T) { _, err = ParseSnowflakeMetadata(properties) assert.NoError(t, err) - properties["workerBits"] = "a" + properties["keyTimeout"] = "a" + _, err = ParseSnowflakeMetadata(properties) + assert.Error(t, err) + + properties["reqTimeout"] = "a" _, err = ParseSnowflakeMetadata(properties) assert.Error(t, err) - properties["workerBits"] = "" properties["startTime"] = "2022.01.01" _, err = ParseSnowflakeMetadata(properties) assert.Error(t, err) - properties["startTime"] = "2022-01-01" properties["workerBits"] = "1" properties["timeBits"] = "1" properties["seqBits"] = "1" _, err = ParseSnowflakeMetadata(properties) assert.Error(t, err) + + properties["workerBits"] = "a" + _, err = ParseSnowflakeMetadata(properties) + assert.Error(t, err) } func TestGetMysqlPort(t *testing.T) { @@ -71,7 +77,7 @@ func TestNewMysqlClient(t *testing.T) { m := SnowflakeMysqlMetadata{} m.Db = db - workId, err := NewMysqlClient(m) + workId, err := NewMysqlClient(&m) assert.NoError(t, err) assert.Equal(t, workId, int64(1)) } diff --git a/components/sequencer/snowflake/snowflake_sequencer.go b/components/sequencer/snowflake/snowflake_sequencer.go index 1a07983bc1..86c9c1718f 100755 --- a/components/sequencer/snowflake/snowflake_sequencer.go +++ b/components/sequencer/snowflake/snowflake_sequencer.go @@ -17,6 +17,7 @@ import ( "context" "database/sql" "errors" + "sync" "time" "mosn.io/pkg/log" @@ -27,8 +28,10 @@ import ( type SnowFlakeSequencer struct { metadata utils.SnowflakeMetadata - ch chan int64 + workerId int64 + mu sync.Mutex db *sql.DB + smap map[string]chan int64 biggerThan map[string]int64 logger log.ErrorLogger ctx context.Context @@ -37,81 +40,142 @@ type SnowFlakeSequencer struct { func NewSnowFlakeSequencer(logger log.ErrorLogger) *SnowFlakeSequencer { return &SnowFlakeSequencer{ - ch: make(chan int64, 1000), logger: logger, } } func (s *SnowFlakeSequencer) Init(config sequencer.Configuration) error { - sm, err := utils.ParseSnowflakeMetadata(config.Properties) + var err error + s.metadata, err = utils.ParseSnowflakeMetadata(config.Properties) if err != nil { return err } //for unit test - sm.MysqlMetadata.Db = s.db + s.metadata.MysqlMetadata.Db = s.db - s.metadata = sm + s.smap = make(map[string]chan int64) s.biggerThan = config.BiggerThan s.ctx, s.cancel = context.WithCancel(context.Background()) - var workId int64 - if workId, err = utils.NewMysqlClient(*s.metadata.MysqlMetadata); err != nil { + if s.workerId, err = utils.NewMysqlClient(&s.metadata.MysqlMetadata); err != nil { return err } + return err +} - timestampShift := sm.SeqBits - workidShift := sm.TimeBits + sm.SeqBits - - currentTimeStamp := time.Now().Unix() - sm.StartTime - - var sequence int64 - startId := workId< Date: Thu, 13 Oct 2022 14:07:19 +0800 Subject: [PATCH 37/45] fix --- components/pkg/utils/snowflake.go | 84 ++++++++++++++++++------------- 1 file changed, 50 insertions(+), 34 deletions(-) diff --git a/components/pkg/utils/snowflake.go b/components/pkg/utils/snowflake.go index 6ef89e31f1..0986c5ba73 100755 --- a/components/pkg/utils/snowflake.go +++ b/components/pkg/utils/snowflake.go @@ -47,8 +47,8 @@ const ( defaultWorkerBits = 22 defaultSeqBits = 13 defaultStartTime = "2022-01-01" - defaultReqTimeout = 500 * time.Millisecond - defaultKeyTimeout = 24 * time.Hour + defaultReqTimeout = 500 + defaultKeyTimeout = 24 ) type SnowflakeMetadata struct { @@ -60,7 +60,6 @@ type SnowflakeMetadata struct { WorkidShift int64 TimestampShift int64 StartTime int64 - WorkId int64 ReqTimeout time.Duration KeyTimeout time.Duration LogInfo bool @@ -116,33 +115,56 @@ func ParseSnowflakeMysqlMetadata(properties map[string]string) (SnowflakeMysqlMe return mm, nil } +func Parsebits(val string, defaultVal int64) (int64, error) { + var bits int64 + var err error + if val != "" { + if bits, err = strconv.ParseInt(val, 10, 64); err != nil { + return bits, err + } + } else { + bits = defaultVal + } + return bits, nil +} + +func Parsetime(val string, defaultVal int) (int, error) { + var parsedVal int + var err error + + if val != "" { + parsedVal, err = strconv.Atoi(val) + if err != nil { + return parsedVal, err + } + } else { + parsedVal = defaultVal + } + return parsedVal, nil +} + func ParseSnowflakeMetadata(properties map[string]string) (SnowflakeMetadata, error) { metadata := SnowflakeMetadata{} var err error - mm, err := ParseSnowflakeMysqlMetadata(properties) + metadata.MysqlMetadata, err = ParseSnowflakeMysqlMetadata(properties) if err != nil { return metadata, err } - metadata.MysqlMetadata = mm - metadata.WorkerBits = defaultWorkerBits - if val, ok := properties[workerBits]; ok && val != "" { - if metadata.WorkerBits, err = strconv.ParseInt(val, 10, 64); err != nil { - return metadata, err - } + metadata.WorkerBits, err = Parsebits(properties[workerBits], defaultWorkerBits) + if err != nil { + return metadata, err } - metadata.TimeBits = defaultTimeBits - if val, ok := properties[timeBits]; ok && val != "" { - if metadata.TimeBits, err = strconv.ParseInt(val, 10, 64); err != nil { - return metadata, err - } + + metadata.TimeBits, err = Parsebits(properties[timeBits], defaultTimeBits) + if err != nil { + return metadata, err } - metadata.SeqBits = defaultSeqBits - if val, ok := properties[seqBits]; ok && val != "" { - if metadata.SeqBits, err = strconv.ParseInt(val, 10, 64); err != nil { - return metadata, err - } + + metadata.SeqBits, err = Parsebits(properties[seqBits], defaultSeqBits) + if err != nil { + return metadata, err } if metadata.TimeBits+metadata.WorkerBits+metadata.SeqBits+1 != 64 { @@ -159,23 +181,17 @@ func ParseSnowflakeMetadata(properties map[string]string) (SnowflakeMetadata, er } metadata.StartTime = tmp.Unix() - metadata.ReqTimeout = defaultReqTimeout - if val, ok := properties[reqTimeout]; ok && val != "" { - parsedVal, err := strconv.Atoi(val) - if err != nil { - return metadata, err - } - metadata.ReqTimeout = time.Duration(parsedVal) * time.Millisecond + parsedReqTimeout, err := Parsetime(properties[reqTimeout], defaultReqTimeout) + if err != nil { + return metadata, err } + metadata.ReqTimeout = time.Duration(parsedReqTimeout) * time.Millisecond - metadata.KeyTimeout = defaultKeyTimeout - if val, ok := properties[keyTimeout]; ok && val != "" { - parsedVal, err := strconv.Atoi(val) - if err != nil { - return metadata, err - } - metadata.KeyTimeout = time.Duration(parsedVal) * time.Hour + parsedKeyTimeout, err := Parsetime(properties[keyTimeout], defaultKeyTimeout) + if err != nil { + return metadata, err } + metadata.KeyTimeout = time.Duration(parsedKeyTimeout) * time.Hour metadata.TimestampShift = metadata.WorkerBits + metadata.SeqBits metadata.WorkidShift = metadata.SeqBits From a16d23be377c1806663890cef1304d5ee551581a Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Thu, 13 Oct 2022 15:17:30 +0800 Subject: [PATCH 38/45] fix --- .../snowflake/snowflake_sequencer.go | 176 +++++++++++------- .../snowflake/snowflake_sequencer_test.go | 72 +++++-- 2 files changed, 162 insertions(+), 86 deletions(-) diff --git a/components/sequencer/snowflake/snowflake_sequencer.go b/components/sequencer/snowflake/snowflake_sequencer.go index 86c9c1718f..9a47cb2ba9 100755 --- a/components/sequencer/snowflake/snowflake_sequencer.go +++ b/components/sequencer/snowflake/snowflake_sequencer.go @@ -88,77 +88,7 @@ func (s *SnowFlakeSequencer) GetNextId(req *sequencer.GetNextIdRequest) (*sequen var workerId = s.workerId startId := cts< Date: Thu, 13 Oct 2022 17:00:37 +0800 Subject: [PATCH 39/45] fix --- .../snowflake/snowflake_sequencer.go | 25 +------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/components/sequencer/snowflake/snowflake_sequencer.go b/components/sequencer/snowflake/snowflake_sequencer.go index 9a47cb2ba9..cb491f173f 100755 --- a/components/sequencer/snowflake/snowflake_sequencer.go +++ b/components/sequencer/snowflake/snowflake_sequencer.go @@ -87,6 +87,7 @@ func (s *SnowFlakeSequencer) GetNextId(req *sequencer.GetNextIdRequest) (*sequen var sequence int64 var workerId = s.workerId startId := cts< Date: Sat, 15 Oct 2022 15:13:15 +0800 Subject: [PATCH 40/45] fix --- components/pkg/utils/snowflake.go | 27 ++++++ .../snowflake/snowflake_sequencer.go | 85 ++++++------------- .../snowflake/snowflake_sequencer_test.go | 13 ++- 3 files changed, 61 insertions(+), 64 deletions(-) diff --git a/components/pkg/utils/snowflake.go b/components/pkg/utils/snowflake.go index 0986c5ba73..97b22d4765 100755 --- a/components/pkg/utils/snowflake.go +++ b/components/pkg/utils/snowflake.go @@ -292,6 +292,33 @@ func NewWorkId(meta SnowflakeMysqlMetadata) (int64, error) { return workId, nil } +func MysqlRecord(db *sql.DB, keyTableName, key string, workerId, timestamp int64) error { + var mysqlWorkerId int64 + var mysqlTimestamp int64 + + begin, err := db.Begin() + if err != nil { + return err + } + err = begin.QueryRow("SELECT WORKER_ID, TIMESTAMP FROM "+keyTableName+" WHERE SEQUENCER_KEY = ?", key).Scan(&mysqlWorkerId, &mysqlTimestamp) + if err == sql.ErrNoRows { + _, err = begin.Exec("INSERT INTO "+keyTableName+"(SEQUENCER_KEY, WORKER_ID, TIMESTAMP) VALUES(?,?,?)", key, workerId, timestamp) + if err != nil { + return err + } + } else { + _, err = begin.Exec("UPDATE INTO "+keyTableName+"(SEQUENCER_KEY, WORKER_ID, TIMESTAMP) VALUES(?,?,?)", key, workerId, timestamp) + if err != nil { + return err + } + } + if err = begin.Commit(); err != nil { + begin.Rollback() + return err + } + return err +} + func getMysqlPort() string { currentTimeMills := time.Now().Unix() rand.Seed(time.Now().UnixNano()) diff --git a/components/sequencer/snowflake/snowflake_sequencer.go b/components/sequencer/snowflake/snowflake_sequencer.go index cb491f173f..fb50da29e9 100755 --- a/components/sequencer/snowflake/snowflake_sequencer.go +++ b/components/sequencer/snowflake/snowflake_sequencer.go @@ -29,8 +29,8 @@ import ( type SnowFlakeSequencer struct { metadata utils.SnowflakeMetadata workerId int64 - mu sync.Mutex db *sql.DB + mu sync.Mutex smap map[string]chan int64 biggerThan map[string]int64 logger log.ErrorLogger @@ -41,6 +41,7 @@ type SnowFlakeSequencer struct { func NewSnowFlakeSequencer(logger log.ErrorLogger) *SnowFlakeSequencer { return &SnowFlakeSequencer{ logger: logger, + smap: make(map[string]chan int64), } } @@ -53,7 +54,6 @@ func (s *SnowFlakeSequencer) Init(config sequencer.Configuration) error { //for unit test s.metadata.MysqlMetadata.Db = s.db - s.smap = make(map[string]chan int64) s.biggerThan = config.BiggerThan s.ctx, s.cancel = context.WithCancel(context.Background()) @@ -65,45 +65,44 @@ func (s *SnowFlakeSequencer) Init(config sequencer.Configuration) error { func (s *SnowFlakeSequencer) GetNextId(req *sequencer.GetNextIdRequest) (*sequencer.GetNextIdResponse, error) { s.mu.Lock() - var ok bool - seed, ok := s.smap[req.Key] + ch, ok := s.smap[req.Key] //If the key appears for the first time, start a new goroutine for it. If the key doesn't appear for a long time, close the goroutine if !ok { - seed = make(chan int64, 1000) - s.smap[req.Key] = seed + ch = make(chan int64, 1000) + s.smap[req.Key] = ch var oldWorkerId int64 var oldTimeStamp int64 - currentTimeStamp := time.Now().Unix() - s.metadata.StartTime - cts := currentTimeStamp + + timestamp := time.Now().Unix() - s.metadata.StartTime err := s.metadata.MysqlMetadata.Db.QueryRow("SELECT WORKER_ID, TIMESTAMP FROM "+s.metadata.MysqlMetadata.KeyTableName+" WHERE SEQUENCER_KEY = ?", req.Key).Scan(&oldWorkerId, &oldTimeStamp) if err == nil { if oldWorkerId == s.workerId { - cts = oldTimeStamp + 1 + timestamp = oldTimeStamp + 1 } } + startId := timestamp< Date: Mon, 17 Oct 2022 23:22:40 +0800 Subject: [PATCH 41/45] fix --- .../snowflake/snowflake_sequencer.go | 28 ++++++++----------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/components/sequencer/snowflake/snowflake_sequencer.go b/components/sequencer/snowflake/snowflake_sequencer.go index fb50da29e9..69776cdf58 100755 --- a/components/sequencer/snowflake/snowflake_sequencer.go +++ b/components/sequencer/snowflake/snowflake_sequencer.go @@ -92,19 +92,16 @@ func (s *SnowFlakeSequencer) GetNextId(req *sequencer.GetNextIdRequest) (*sequen defer timeout.Stop() var id int64 - for { - timeout.Reset(s.metadata.ReqTimeout) - select { - case id, ok = <-ch: - if !ok { - return nil, errors.New("please try again or adjust the start time") - } - return &sequencer.GetNextIdResponse{ - NextId: id, - }, nil - case <-timeout.C: - return nil, errors.New("request id time out") + select { + case id, ok = <-ch: + if !ok { + return nil, errors.New("please try again or adjust the start time") } + return &sequencer.GetNextIdResponse{ + NextId: id, + }, nil + case <-timeout.C: + return nil, errors.New("request id time out") } } @@ -147,11 +144,8 @@ func (s *SnowFlakeSequencer) producer(id, currentTimeStamp int64, ch chan int64, return case ch <- id: if currentTimeStamp == maxTimeStamp { - //if id reach the max value, wait for the id to be used up - if len(ch) == 0 { - close(ch) - return - } + close(ch) + return } else { if id&maxSeqId != maxSeqId { id++ From 15602af7211c04d7fdeefaec75c620c6a2f9b2e0 Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Tue, 18 Oct 2022 10:38:08 +0800 Subject: [PATCH 42/45] fix --- components/sequencer/snowflake/snowflake_sequencer.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/components/sequencer/snowflake/snowflake_sequencer.go b/components/sequencer/snowflake/snowflake_sequencer.go index 69776cdf58..b62ee306b4 100755 --- a/components/sequencer/snowflake/snowflake_sequencer.go +++ b/components/sequencer/snowflake/snowflake_sequencer.go @@ -146,13 +146,12 @@ func (s *SnowFlakeSequencer) producer(id, currentTimeStamp int64, ch chan int64, if currentTimeStamp == maxTimeStamp { close(ch) return + } + if id&maxSeqId != maxSeqId { + id++ } else { - if id&maxSeqId != maxSeqId { - id++ - } else { - currentTimeStamp++ - id = currentTimeStamp< Date: Tue, 18 Oct 2022 21:46:35 +0800 Subject: [PATCH 43/45] fix --- components/pkg/utils/snowflake_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/components/pkg/utils/snowflake_test.go b/components/pkg/utils/snowflake_test.go index 14398c5eeb..5635e2bf1e 100644 --- a/components/pkg/utils/snowflake_test.go +++ b/components/pkg/utils/snowflake_test.go @@ -68,6 +68,7 @@ func TestNewMysqlClient(t *testing.T) { t.Fatalf("an error '%s' was not expected when opening a stub database connection", err) } + mock.ExpectExec("CREATE TABLE").WillReturnResult(sqlmock.NewResult(1, 1)) mock.ExpectExec("CREATE TABLE").WillReturnResult(sqlmock.NewResult(1, 1)) mock.ExpectBegin() mock.ExpectQuery("SELECT HOST_NAME").WillReturnError(sql.ErrNoRows) From 0ba7e989d9a987a57130c6da4323ccbf47fe7622 Mon Sep 17 00:00:00 2001 From: lh <321642771@qq.com> Date: Wed, 19 Oct 2022 18:41:11 +0800 Subject: [PATCH 44/45] fix --- components/pkg/utils/snowflake.go | 14 ++++++++++---- .../sequencer/snowflake/snowflake_sequencer.go | 2 ++ .../snowflake/snowflake_sequencer_test.go | 3 +++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/components/pkg/utils/snowflake.go b/components/pkg/utils/snowflake.go index 97b22d4765..ec9cd5b5de 100755 --- a/components/pkg/utils/snowflake.go +++ b/components/pkg/utils/snowflake.go @@ -269,6 +269,9 @@ func NewWorkId(meta SnowflakeMysqlMetadata) (int64, error) { for err == nil { mysqlPort = getMysqlPort() err = begin.QueryRow("SELECT HOST_NAME, PORT FROM "+tableName+" WHERE HOST_NAME = ? AND PORT = ?", stringIp, mysqlPort).Scan(&host_name, &port) + if err != nil && err != sql.ErrNoRows { + return workId, err + } } if err == sql.ErrNoRows { _, err = begin.Exec("INSERT INTO "+tableName+"(HOST_NAME, PORT, CREATED) VALUES(?,?,?)", stringIp, mysqlPort, time.Now()) @@ -301,16 +304,19 @@ func MysqlRecord(db *sql.DB, keyTableName, key string, workerId, timestamp int64 return err } err = begin.QueryRow("SELECT WORKER_ID, TIMESTAMP FROM "+keyTableName+" WHERE SEQUENCER_KEY = ?", key).Scan(&mysqlWorkerId, &mysqlTimestamp) - if err == sql.ErrNoRows { - _, err = begin.Exec("INSERT INTO "+keyTableName+"(SEQUENCER_KEY, WORKER_ID, TIMESTAMP) VALUES(?,?,?)", key, workerId, timestamp) + if err == nil { + _, err = begin.Exec("UPDATE INTO "+keyTableName+"(SEQUENCER_KEY, WORKER_ID, TIMESTAMP) VALUES(?,?,?)", key, workerId, timestamp) + if err != nil { return err } - } else { - _, err = begin.Exec("UPDATE INTO "+keyTableName+"(SEQUENCER_KEY, WORKER_ID, TIMESTAMP) VALUES(?,?,?)", key, workerId, timestamp) + } else if err == sql.ErrNoRows { + _, err = begin.Exec("INSERT INTO "+keyTableName+"(SEQUENCER_KEY, WORKER_ID, TIMESTAMP) VALUES(?,?,?)", key, workerId, timestamp) if err != nil { return err } + } else { + return err } if err = begin.Commit(); err != nil { begin.Rollback() diff --git a/components/sequencer/snowflake/snowflake_sequencer.go b/components/sequencer/snowflake/snowflake_sequencer.go index b62ee306b4..e32cfea333 100755 --- a/components/sequencer/snowflake/snowflake_sequencer.go +++ b/components/sequencer/snowflake/snowflake_sequencer.go @@ -81,6 +81,8 @@ func (s *SnowFlakeSequencer) GetNextId(req *sequencer.GetNextIdRequest) (*sequen if oldWorkerId == s.workerId { timestamp = oldTimeStamp + 1 } + } else if err != sql.ErrNoRows { + return nil, err } startId := timestamp< Date: Thu, 20 Oct 2022 13:31:06 +0800 Subject: [PATCH 45/45] fix --- .../snowflake}/snowflake.go | 4 +-- .../snowflake/snowflake_sequencer.go | 9 +++-- .../snowflake/snowflake_sequencer_test.go | 35 +++++++------------ .../snowflake}/snowflake_test.go | 2 +- 4 files changed, 19 insertions(+), 31 deletions(-) rename components/{pkg/utils => sequencer/snowflake}/snowflake.go (99%) rename components/{pkg/utils => sequencer/snowflake}/snowflake_test.go (99%) diff --git a/components/pkg/utils/snowflake.go b/components/sequencer/snowflake/snowflake.go similarity index 99% rename from components/pkg/utils/snowflake.go rename to components/sequencer/snowflake/snowflake.go index ec9cd5b5de..27da647b20 100755 --- a/components/pkg/utils/snowflake.go +++ b/components/sequencer/snowflake/snowflake.go @@ -11,7 +11,7 @@ // 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 utils +package snowflake import ( "database/sql" @@ -79,7 +79,7 @@ type SnowflakeMysqlMetadata struct { func ParseSnowflakeMysqlMetadata(properties map[string]string) (SnowflakeMysqlMetadata, error) { mm := SnowflakeMysqlMetadata{} - mm.TableName = defaultTableName + mm.TableName = defaultMysqlTableName if val, ok := properties[mysqlTableName]; ok && val != "" { mm.TableName = val } diff --git a/components/sequencer/snowflake/snowflake_sequencer.go b/components/sequencer/snowflake/snowflake_sequencer.go index e32cfea333..1a52bab045 100755 --- a/components/sequencer/snowflake/snowflake_sequencer.go +++ b/components/sequencer/snowflake/snowflake_sequencer.go @@ -22,12 +22,11 @@ import ( "mosn.io/pkg/log" - "mosn.io/layotto/components/pkg/utils" "mosn.io/layotto/components/sequencer" ) type SnowFlakeSequencer struct { - metadata utils.SnowflakeMetadata + metadata SnowflakeMetadata workerId int64 db *sql.DB mu sync.Mutex @@ -47,7 +46,7 @@ func NewSnowFlakeSequencer(logger log.ErrorLogger) *SnowFlakeSequencer { func (s *SnowFlakeSequencer) Init(config sequencer.Configuration) error { var err error - s.metadata, err = utils.ParseSnowflakeMetadata(config.Properties) + s.metadata, err = ParseSnowflakeMetadata(config.Properties) if err != nil { return err } @@ -57,7 +56,7 @@ func (s *SnowFlakeSequencer) Init(config sequencer.Configuration) error { s.biggerThan = config.BiggerThan s.ctx, s.cancel = context.WithCancel(context.Background()) - if s.workerId, err = utils.NewMysqlClient(&s.metadata.MysqlMetadata); err != nil { + if s.workerId, err = NewMysqlClient(&s.metadata.MysqlMetadata); err != nil { return err } return err @@ -138,7 +137,7 @@ func (s *SnowFlakeSequencer) producer(id, currentTimeStamp int64, ch chan int64, delete(s.smap, key) close(ch) - err := utils.MysqlRecord(s.metadata.MysqlMetadata.Db, s.metadata.MysqlMetadata.KeyTableName, key, s.workerId, currentTimeStamp) + err := MysqlRecord(s.metadata.MysqlMetadata.Db, s.metadata.MysqlMetadata.KeyTableName, key, s.workerId, currentTimeStamp) if err != nil { s.logger.Errorf("%v", err) } diff --git a/components/sequencer/snowflake/snowflake_sequencer_test.go b/components/sequencer/snowflake/snowflake_sequencer_test.go index 4698c456f5..1f6c1f1cc3 100755 --- a/components/sequencer/snowflake/snowflake_sequencer_test.go +++ b/components/sequencer/snowflake/snowflake_sequencer_test.go @@ -29,18 +29,11 @@ import ( ) const ( - mysqlHost = "localhost:3306" + mysqlHostUrl = "localhost:3306" databaseName = "layotto_sequencer" - tableName = "layotto_sequencer_snowflake" userName = "root" password = "123456" - - timeBits = "28" - workerBits = "22" - seqBits = "13" - startTime = "2022-01-01" - - key = "resource_xxx" + key = "resource_xxx" ) func TestSnowflakeSequence_GetNextId(t *testing.T) { @@ -66,16 +59,16 @@ func TestSnowflakeSequence_GetNextId(t *testing.T) { BiggerThan: make(map[string]int64), } - cfg.Properties["mysqlHost"] = mysqlHost + cfg.Properties["mysqlHost"] = mysqlHostUrl cfg.Properties["databaseName"] = databaseName - cfg.Properties["tableName"] = tableName + cfg.Properties["tableName"] = defaultMysqlTableName cfg.Properties["userName"] = userName cfg.Properties["password"] = password - cfg.Properties["timeBits"] = timeBits - cfg.Properties["workerBits"] = workerBits - cfg.Properties["seqBits"] = seqBits - cfg.Properties["startTime"] = startTime + cfg.Properties["timeBits"] = "28" + cfg.Properties["workerBits"] = "22" + cfg.Properties["seqBits"] = "13" + cfg.Properties["startTime"] = "2022-01-01" err = s.Init(cfg) @@ -122,9 +115,9 @@ func TestSnowflakeSequence_ParallelGetNextId(t *testing.T) { BiggerThan: make(map[string]int64), } - cfg.Properties["mysqlHost"] = mysqlHost + cfg.Properties["mysqlHost"] = mysqlHostUrl cfg.Properties["databaseName"] = databaseName - cfg.Properties["tableName"] = tableName + cfg.Properties["tableName"] = defaultMysqlTableName cfg.Properties["userName"] = userName cfg.Properties["password"] = password @@ -192,16 +185,12 @@ func TestKeyTimeout(t *testing.T) { BiggerThan: make(map[string]int64), } - cfg.Properties["mysqlHost"] = mysqlHost + cfg.Properties["mysqlHost"] = mysqlHostUrl cfg.Properties["databaseName"] = databaseName - cfg.Properties["tableName"] = tableName + cfg.Properties["tableName"] = defaultMysqlTableName cfg.Properties["userName"] = userName cfg.Properties["password"] = password - cfg.Properties["timeBits"] = timeBits - cfg.Properties["workerBits"] = workerBits - cfg.Properties["seqBits"] = seqBits - cfg.Properties["startTime"] = startTime cfg.Properties["keyTimeout"] = "0" err = s.Init(cfg) diff --git a/components/pkg/utils/snowflake_test.go b/components/sequencer/snowflake/snowflake_test.go similarity index 99% rename from components/pkg/utils/snowflake_test.go rename to components/sequencer/snowflake/snowflake_test.go index 5635e2bf1e..99daa31ecc 100644 --- a/components/pkg/utils/snowflake_test.go +++ b/components/sequencer/snowflake/snowflake_test.go @@ -11,7 +11,7 @@ // 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 utils +package snowflake import ( "database/sql"