mirror of
https://github.com/grafana/grafana.git
synced 2026-07-29 15:59:50 -05:00
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:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user