Skip to content

Commit

Permalink
Merge pull request #6 from storage-lock/dev
Browse files Browse the repository at this point in the history
feat: 删除错误的更新条件
  • Loading branch information
CC11001100 committed Sep 10, 2023
2 parents 324ece0 + e064ba4 commit fd42135
Show file tree
Hide file tree
Showing 3 changed files with 7 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
3 changes: 3 additions & 0 deletions scripts/mongodb.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env bash

# 删除之前已经启动过的容器
docker rm -f storage-lock-mongodb

# 启动Docker容器
docker run -d -p 27017:27017 --name storage-lock-mongodb -e MONGO_INITDB_ROOT_USERNAME=root -e MONGO_INITDB_ROOT_PASSWORD=UeGqAm8CxYGldMDLoNNt mongo

Expand Down

0 comments on commit fd42135

Please sign in to comment.