serverlock

package
v0.0.0-test Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2021 License: AGPL-3.0 Imports: 4 Imported by: 196

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ServerLockService

type ServerLockService struct {
	SQLStore *sqlstore.SQLStore
	// contains filtered or unexported fields
}

ServerLockService allows servers in HA mode to claim a lock and execute an function if the server was granted the lock

func ProvideService

func ProvideService(sqlStore *sqlstore.SQLStore) *ServerLockService

func (*ServerLockService) LockAndExecute

func (sl *ServerLockService) LockAndExecute(ctx context.Context, actionName string, maxInterval time.Duration, fn func(ctx context.Context)) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL