protect counter race condition
This commit is contained in:
parent
dbab92f317
commit
d176afa7ec
1 changed files with 4 additions and 0 deletions
|
|
@ -321,8 +321,12 @@ func (fc *fakeCheckpoint) Get(streamName, shardID string) (string, error) {
|
|||
// implementation of counter
|
||||
type fakeCounter struct {
|
||||
counter int64
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func (fc *fakeCounter) Add(streamName string, count int64) {
|
||||
fc.mu.Lock()
|
||||
defer fc.mu.Unlock()
|
||||
|
||||
fc.counter += count
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue