mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-08 10:08:42 +08:00
24 lines
398 B
Go
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
|
|
}
|