Chore: Add context to user (#39649)

* Add context to user

* Add context for enterprise

* Add context for UpdateUserLastSeenAtCommand

* Remove xorm
This commit is contained in:
idafurjes
2021-10-04 15:46:09 +02:00
committed by GitHub
parent 42d7c32759
commit f4f0d74838
11 changed files with 152 additions and 145 deletions
+2 -2
View File
@@ -25,7 +25,7 @@ type ServerLockService struct {
// LockAndExecute try to create a lock for this server and only executes the
// `fn` function when successful. This should not be used at low internal. But services
// that needs to be run once every ex 10m.
func (sl *ServerLockService) LockAndExecute(ctx context.Context, actionName string, maxInterval time.Duration, fn func()) error {
func (sl *ServerLockService) LockAndExecute(ctx context.Context, actionName string, maxInterval time.Duration, fn func(ctx context.Context)) error {
// gets or creates a lockable row
rowLock, err := sl.getOrCreate(ctx, actionName)
if err != nil {
@@ -47,7 +47,7 @@ func (sl *ServerLockService) LockAndExecute(ctx context.Context, actionName stri
}
if acquiredLock {
fn()
fn(ctx)
}
return nil
@@ -15,7 +15,7 @@ func TestServerLok(t *testing.T) {
sl := createTestableServerLock(t)
counter := 0
fn := func() { counter++ }
fn := func(context.Context) { counter++ }
atInterval := time.Second * 1
ctx := context.Background()