njob

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DistributedMutex

type DistributedMutex interface {
	TryRunWithMutex(key string, timeout time.Duration, fn func()) error
}

DistributedMutex -

func NewRedisDistributedMutex

func NewRedisDistributedMutex(redisOper ndb.RedisOper, lockTimeout time.Duration) DistributedMutex

NewRedisDistributedMutex - This is just an example, and it is recommended to use ETCD for distributed lock. In addition, This pattern is discouraged in favor of the Redlock(https://redis.io/topics/distlock) algorithm which is only a bit more complex to implement, but offers better guarantees and is fault tolerant.

type FuncJob

type FuncJob func(ctx context.Context) error

FuncJob -

func (FuncJob) Run

func (f FuncJob) Run(ctx context.Context) error

Run -

type FuncJobs

type FuncJobs map[string]FuncJob

FuncJobs -

type Job

type Job interface {
	Run(ctx context.Context) error
}

Job -

type Jobs

type Jobs map[string]Job

Jobs -

type Server

type Server interface {
	graceful.ShutdownServer
}

Server -

func MustNewServer

func MustNewServer(config *nconf.Config, opt ...ServerOption) Server

MustNewServer -

func NewServer

func NewServer(config *nconf.Config, opt ...ServerOption) (Server, error)

NewServer -

type ServerOption

type ServerOption func(*serverOptions)

ServerOption -

func DistributedMutexOption

func DistributedMutexOption(distributedMutex DistributedMutex) ServerOption

DistributedMutexOption -

func FuncJobsOption

func FuncJobsOption(funcJobs FuncJobs) ServerOption

FuncJobsOption -

func JobsOption

func JobsOption(jobs Jobs) ServerOption

JobsOption -

Jump to

Keyboard shortcuts

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