milvus/internal/proxy/mock/mock_master_tso.go
shengjh 77b2fcf015 Refactor manipulationreq and add tso(pre-alloc from master)
Signed-off-by: shengjh <1572099106@qq.com>
2020-10-27 12:01:27 +08:00

24 lines
398 B
Go

package mock
import (
"context"
"sync"
"time"
)
const timeWindow = time.Second
type TSOClient struct {
lastTs uint64
mux sync.Mutex
}
// window is 1000ms default
func (c *TSOClient) GetTimeStamp(ctx context.Context, n uint64) (ts uint64, count uint64, window time.Duration, err error) {
c.mux.Lock()
defer c.mux.Unlock()
ts = c.lastTs
c.lastTs += n
return ts, n, timeWindow, nil
}