Documentation ¶
Index ¶
- func Enqueue(appName string, argument interface{}, queue string, redisStorage *RedisStorage) (uuid.UUID, error)
- func StartServer(sqlStorage SqlStorage, config *Configuration) error
- type Application
- type Argument
- type BackgroundJob
- type Configuration
- type DistributedLock
- type Job
- func EnqueueAfter(appName string, argument interface{}, bgJobId uuid.UUID, queue string, ...) (*Job, error)
- func NewJob(appName string, argument interface{}, startAt *time.Time, ...) *Job
- func Schedule(appName string, argument interface{}, startAt time.Time, queue string, ...) (*Job, error)
- func Subscribe(appName string, argument interface{}, recurPattern recur.RecurringPattern, ...) (*Job, error)
- type JobArgument
- type JobError
- type JobLog
- type JobStatus
- type JobType
- type LongTermStorageType
- type PassArgumentType
- type Queue
- type RedisStorage
- func (redisStorage *RedisStorage) AddJobLog(BackgroundJobId uuid.UUID, log *JobLog)
- func (redisStorage *RedisStorage) DeleteBackgroundJob(bgJob *BackgroundJob)
- func (redisStorage *RedisStorage) DeleteBackgroundJobs(bgJobs []*BackgroundJob)
- func (redisStorage *RedisStorage) DeleteDistributedLock(key string, id string)
- func (redisStorage *RedisStorage) DeleteExpired() error
- func (redisStorage *RedisStorage) DeleteJob(job *Job)
- func (redisStorage *RedisStorage) Dequeue(queue string) uuid.UUID
- func (redisStorage *RedisStorage) DistributedLocksCount(key string) int64
- func (redisStorage *RedisStorage) EnqueueAfter(jobId uuid.UUID, bgJobId uuid.UUID) error
- func (redisStorage *RedisStorage) GetAllDistributedLocks() []*DistributedLock
- func (redisStorage *RedisStorage) GetAllJobs(status JobStatus) ([]*BackgroundJob, int)
- func (redisStorage *RedisStorage) GetBackgroundJob(backgroundJobId uuid.UUID, includeDetails bool) *BackgroundJob
- func (redisStorage *RedisStorage) GetJob(jobId uuid.UUID, loadLatest bool) *Job
- func (redisStorage *RedisStorage) GetJobLogs(backgroundJobId uuid.UUID) []*JobLog
- func (redisStorage *RedisStorage) GetJobs(serverId uuid.UUID, queue string) []*Job
- func (redisStorage *RedisStorage) GetServer(server *Server)
- func (redisStorage *RedisStorage) GetServerJobs(serverId uuid.UUID, queue string) []*BackgroundJob
- func (redisStorage *RedisStorage) HasRunningJobs(serverId uuid.UUID) bool
- func (redisStorage *RedisStorage) IsDistributedLockEntered(key string, id string) bool
- func (redisStorage *RedisStorage) JobEnqueued(jobId uuid.UUID, queue string)
- func (redisStorage *RedisStorage) SaveBackgroundJob(bgJob *BackgroundJob) error
- func (redisStorage *RedisStorage) SaveDistributedLock(distLock *DistributedLock)
- func (redisStorage *RedisStorage) SaveJob(job *Job, forceUpdate bool) error
- func (redisStorage *RedisStorage) SaveServer(server *Server)
- func (redisStorage *RedisStorage) ScheduleChanged(serverId uuid.UUID, queue string) bool
- type Server
- type ServerStatus
- type SqlStorage
- type StorageType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StartServer ¶
func StartServer(sqlStorage SqlStorage, config *Configuration) error
Types ¶
type Application ¶
type BackgroundJob ¶
type BackgroundJob struct { Id uuid.UUID JobId uuid.UUID Job *Job `json:"-"` ProcessedBy *uuid.UUID Server string CreatedAt time.Time Status JobStatus JobError *string `json:"-"` Error *JobError `json:",omitempty"` StartedAt *time.Time `json:",omitempty"` CompletedAt *time.Time `json:",omitempty"` LastActivity *time.Time `json:",omitempty"` JobLogs []*JobLog `json:"-"` Logs *string `json:"-"` }
type Configuration ¶
type Configuration struct { StorageConfig string LongTermStorageConfig string Applications []*Application Servers []*Server OffDays []time.Weekday StorageType StorageType LongTermStorageType LongTermStorageType EnableStopServers bool EnableDeleteAll bool ConnectionRetries int ConnectionRetryInterval int JobHeartbeatInterval int InactiveJobTimeout int ServerHeartbeatInterval int InactiveServerTimeout int LockHeartbeatInterval int InactiveLockTimeout int StorageExpirationInDays int StorageSyncInterval int StorageSyncBatchSize int CleanStorageInterval int }
func LoadConfiguration ¶
func LoadConfiguration(configPath *string) *Configuration
type DistributedLock ¶
type DistributedLock struct { Id string Key string StartedAt time.Time LastActivity time.Time // contains filtered or unexported fields }
func NewDistributedLock ¶
func NewDistributedLock(key string, start bool, redisStorage *RedisStorage) *DistributedLock
func (*DistributedLock) Enter ¶
func (distLock *DistributedLock) Enter()
func (*DistributedLock) Exit ¶
func (distLock *DistributedLock) Exit()
func (*DistributedLock) TryEnter ¶
func (distLock *DistributedLock) TryEnter() bool
func (*DistributedLock) TryEnterTill ¶
func (distLock *DistributedLock) TryEnterTill(timeout time.Duration) bool
func (*DistributedLock) TryEnterTillMS ¶
func (distLock *DistributedLock) TryEnterTillMS(millisecondsTimeout int) bool
type Job ¶
type Job struct { Id uuid.UUID Name *string `json:",omitempty"` Queue string AppName string JobArgument *JobArgument Argument *string `json:",omitempty"` CreatedAt time.Time IsRecurring bool StartAt *time.Time `json:",omitempty"` Active bool Recurring *string `json:"-"` RecurringPattern *recur.RecurringPattern `json:",omitempty"` Tries int Type JobType AfterBackgroundJobIds *string `json:",omitempty"` BackgroundJobs []*BackgroundJob `json:"-"` }
func EnqueueAfter ¶
type JobArgument ¶
type JobError ¶
func NewJobError ¶
type LongTermStorageType ¶
type LongTermStorageType uint8
const ( SqlServer LongTermStorageType = iota PostgresSQL MySql Oracle )
type RedisStorage ¶
type RedisStorage struct { Config *Configuration // contains filtered or unexported fields }
func Connect ¶
func Connect(config *Configuration) (*RedisStorage, error)
func (*RedisStorage) AddJobLog ¶
func (redisStorage *RedisStorage) AddJobLog(BackgroundJobId uuid.UUID, log *JobLog)
func (*RedisStorage) DeleteBackgroundJob ¶
func (redisStorage *RedisStorage) DeleteBackgroundJob(bgJob *BackgroundJob)
func (*RedisStorage) DeleteBackgroundJobs ¶
func (redisStorage *RedisStorage) DeleteBackgroundJobs(bgJobs []*BackgroundJob)
func (*RedisStorage) DeleteDistributedLock ¶
func (redisStorage *RedisStorage) DeleteDistributedLock(key string, id string)
func (*RedisStorage) DeleteExpired ¶
func (redisStorage *RedisStorage) DeleteExpired() error
func (*RedisStorage) DeleteJob ¶
func (redisStorage *RedisStorage) DeleteJob(job *Job)
func (*RedisStorage) DistributedLocksCount ¶
func (redisStorage *RedisStorage) DistributedLocksCount(key string) int64
func (*RedisStorage) EnqueueAfter ¶
func (*RedisStorage) GetAllDistributedLocks ¶
func (redisStorage *RedisStorage) GetAllDistributedLocks() []*DistributedLock
func (*RedisStorage) GetAllJobs ¶
func (redisStorage *RedisStorage) GetAllJobs(status JobStatus) ([]*BackgroundJob, int)
func (*RedisStorage) GetBackgroundJob ¶
func (redisStorage *RedisStorage) GetBackgroundJob(backgroundJobId uuid.UUID, includeDetails bool) *BackgroundJob
func (*RedisStorage) GetJob ¶
func (redisStorage *RedisStorage) GetJob(jobId uuid.UUID, loadLatest bool) *Job
func (*RedisStorage) GetJobLogs ¶
func (redisStorage *RedisStorage) GetJobLogs(backgroundJobId uuid.UUID) []*JobLog
func (*RedisStorage) GetJobs ¶
func (redisStorage *RedisStorage) GetJobs(serverId uuid.UUID, queue string) []*Job
func (*RedisStorage) GetServer ¶
func (redisStorage *RedisStorage) GetServer(server *Server)
func (*RedisStorage) GetServerJobs ¶
func (redisStorage *RedisStorage) GetServerJobs(serverId uuid.UUID, queue string) []*BackgroundJob
func (*RedisStorage) HasRunningJobs ¶
func (redisStorage *RedisStorage) HasRunningJobs(serverId uuid.UUID) bool
func (*RedisStorage) IsDistributedLockEntered ¶
func (redisStorage *RedisStorage) IsDistributedLockEntered(key string, id string) bool
func (*RedisStorage) JobEnqueued ¶
func (redisStorage *RedisStorage) JobEnqueued(jobId uuid.UUID, queue string)
func (*RedisStorage) SaveBackgroundJob ¶
func (redisStorage *RedisStorage) SaveBackgroundJob(bgJob *BackgroundJob) error
func (*RedisStorage) SaveDistributedLock ¶
func (redisStorage *RedisStorage) SaveDistributedLock(distLock *DistributedLock)
func (*RedisStorage) SaveJob ¶
func (redisStorage *RedisStorage) SaveJob(job *Job, forceUpdate bool) error
func (*RedisStorage) SaveServer ¶
func (redisStorage *RedisStorage) SaveServer(server *Server)
func (*RedisStorage) ScheduleChanged ¶
func (redisStorage *RedisStorage) ScheduleChanged(serverId uuid.UUID, queue string) bool
type Server ¶
type Server struct { Id uuid.UUID Hostname string Queues []*Queue Status ServerStatus StartedAt time.Time LastActivity time.Time HasDataSync bool WorkersCount int // contains filtered or unexported fields }
func (*Server) StartService ¶
func (server *Server) StartService(redisStorage *RedisStorage, sqlStorage SqlStorage)
type SqlStorage ¶
type SqlStorage interface { Connect(config *Configuration) error SaveBackgroundJobs(bgJobs []*BackgroundJob) error DeleteExpired() error }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.