Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Dddfirework
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
bytedance
Dddfirework
Commits
efe8c6c8
Commit
efe8c6c8
authored
1 year ago
by
liqiankun.1111
Browse files
Options
Downloads
Patches
Plain Diff
fix: fix return lock infer
parent
4d8b467c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lock/db/sql.go
+1
-1
1 addition, 1 deletion
lock/db/sql.go
lock/db/sql_test.go
+5
-2
5 additions, 2 deletions
lock/db/sql_test.go
with
6 additions
and
3 deletions
lock/db/sql.go
+
1
−
1
View file @
efe8c6c8
...
@@ -88,7 +88,7 @@ func (r *DBLock) lock(ctx context.Context, key string) (keyLock interface{}, err
...
@@ -88,7 +88,7 @@ func (r *DBLock) lock(ctx context.Context, key string) (keyLock interface{}, err
// resource updated by others
// resource updated by others
return
nil
,
ErrConflict
return
nil
,
ErrConflict
}
}
return
lock
,
nil
return
&
lock
,
nil
}
}
func
(
r
*
DBLock
)
UnLock
(
ctx
context
.
Context
,
keyLock
interface
{})
error
{
func
(
r
*
DBLock
)
UnLock
(
ctx
context
.
Context
,
keyLock
interface
{})
error
{
...
...
This diff is collapsed.
Click to expand it.
lock/db/sql_test.go
+
5
−
2
View file @
efe8c6c8
...
@@ -35,8 +35,11 @@ func TestLock(t *testing.T) {
...
@@ -35,8 +35,11 @@ func TestLock(t *testing.T) {
assert
.
NoError
(
t
,
err
)
assert
.
NoError
(
t
,
err
)
r
:=
l
.
(
*
ResourceLock
)
r
:=
l
.
(
*
ResourceLock
)
assert
.
True
(
t
,
len
(
r
.
LockerID
)
>
0
)
assert
.
True
(
t
,
len
(
r
.
LockerID
)
>
0
)
// 重试5次,至少耗时500ms
// 测试lock 过期场景
_
,
err
=
lock
.
Lock
(
context
.
Background
(),
"abc"
)
time
.
Sleep
(
1
*
time
.
Second
)
l
,
err
=
lock
.
Lock
(
context
.
Background
(),
"abc"
)
assert
.
NoError
(
t
,
err
)
err
=
lock
.
UnLock
(
context
.
Background
(),
l
)
assert
.
NoError
(
t
,
err
)
assert
.
NoError
(
t
,
err
)
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment