Skip to content

Commit

Permalink
feat: 删除错误的更新条件
Browse files Browse the repository at this point in the history
  • Loading branch information
CC11001100 committed Sep 10, 2023
1 parent 93e28e7 commit e064ba4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions mongodb_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,8 @@ func (x *MongoStorage) UpdateWithVersion(ctx context.Context, lockId string, exc
"_id": bson.M{
"$eq": lockId,
},
"owner_id": bson.M{
"$eq": lockInformation.OwnerId,
},
"version": bson.M{
//"$eq": json.Number(strconv.FormatUint(uint64(exceptedVersion), 10)),
"$eq": exceptedVersion,
},
}
Expand Down Expand Up @@ -185,7 +183,9 @@ func (x *MongoStorage) Get(ctx context.Context, lockId string) (string, error) {

func (x *MongoStorage) GetTime(ctx context.Context) (time.Time, error) {
// MongoDB没找到好的办法拿数据库实例的时间,这里就使用一个公共的NTP作为时间源吧
// TODO
return x.timeProvider.GetTime(ctx)
//return time.Now(), nil
}

func (x *MongoStorage) Close(ctx context.Context) error {
Expand Down
2 changes: 1 addition & 1 deletion mongodb_storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"testing"
)

func TestNewMongoStorage(t *testing.T) {
func TestMongoStorage(t *testing.T) {
envName := "STORAGE_LOCK_MONGO_URI"
uri := os.Getenv(envName)
assert.NotEmpty(t, uri)
Expand Down

0 comments on commit e064ba4

Please sign in to comment.