injob

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: Apache-2.0 Imports: 5 Imported by: 9

README

injob

the sysinner's job scheduling and execution library for golang.

License

Apache License, Version 2.0.

Documentation

Index

Constants

View Source
const (
	ActionStart uint64 = 1 << 1
	ActionStop  uint64 = 1 << 2
)
View Source
const (
	Second  = 1 << iota // Second
	Minute              // Minute
	Hour                // Hour
	Day                 // Day of month
	Month               // Month
	Weekday             // Day of week
)
View Source
const (
	StatusOK uint64 = 1 << 1
	StatusER uint64 = 1 << 2
)
View Source
const (
	Version = "0.0.1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	// contains filtered or unexported fields
}

func (*Context) ConditionDel

func (it *Context) ConditionDel(name string) *Context

func (*Context) ConditionRefresh

func (it *Context) ConditionRefresh(name string) *Context

func (*Context) ConditionSet

func (it *Context) ConditionSet(name string, v int64) *Context

type Daemon

type Daemon struct {
	// contains filtered or unexported fields
}

func NewDaemon

func NewDaemon(args ...interface{}) (*Daemon, error)

func (*Daemon) BriefReport

func (it *Daemon) BriefReport() *DaemonBriefReport

func (*Daemon) Commit

func (it *Daemon) Commit(j *JobEntry) *JobEntry

func (*Daemon) Start

func (it *Daemon) Start()

type DaemonBriefReport

type DaemonBriefReport struct {
	Jobs []*DaemonBriefReportJob `json:"jobs" toml:"jobs"`
}

type DaemonBriefReportJob

type DaemonBriefReportJob struct {
	Name    string `json:"name" toml:"name"`
	Message string `json:"message" toml:"message"`
}

type DaemonStatus

type DaemonStatus struct {
	Jobs []*JobStatus `json:"jobs" toml:"jobs"`
}

type Job

type Job interface {
	Spec() *JobSpec
	Run(ctx *Context) error
}

type JobEntry

type JobEntry struct {
	Status *JobStatus
	// contains filtered or unexported fields
}

func NewJobEntry

func NewJobEntry(job Job, sch *Schedule, args ...interface{}) *JobEntry

func (*JobEntry) Commit

func (it *JobEntry) Commit() *JobEntry

func (*JobEntry) Schedule

func (it *JobEntry) Schedule() *Schedule

type JobExecLog

type JobExecLog struct {
	Created int64  `json:"created" toml:"created"`
	Updated int64  `json:"updated" toml:"updated"`
	Status  uint64 `json:"status" toml:"status"`
	Message string `json:"message,omitempty" toml:"message,omitempty"`
}

func (*JobExecLog) ER

func (it *JobExecLog) ER(msg string) *JobExecLog

func (*JobExecLog) OK

func (it *JobExecLog) OK(args ...string) *JobExecLog

type JobSpec

type JobSpec struct {
	Name       string
	Conditions map[string]int64
}

func NewJobSpec

func NewJobSpec(name string) *JobSpec

func (*JobSpec) ConditionSet

func (it *JobSpec) ConditionSet(name string, v int64) *JobSpec

type JobStatus

type JobStatus struct {
	ExecNum      int64         `json:"exec_num" toml:"exec_num"`
	NextExecTime int64         `json:"next_exec_time" toml:"next_exec_time"`
	ExecLogs     []*JobExecLog `json:"exec_logs" toml:"exec_logs"`
	// contains filtered or unexported fields
}

func (*JobStatus) LastLog

func (it *JobStatus) LastLog() *JobExecLog

func (*JobStatus) LogSync

func (it *JobStatus) LogSync(log *JobExecLog)

type Schedule

type Schedule struct {
	// contains filtered or unexported fields
}

func NewSchedule

func NewSchedule() *Schedule

func (*Schedule) EveryTime

func (it *Schedule) EveryTime(opt int, in uint) *Schedule

func (*Schedule) EveryTimeCycle

func (it *Schedule) EveryTimeCycle(opt int, in uint) *Schedule

func (*Schedule) Hit

func (it *Schedule) Hit(times [6]uint64) bool

func (*Schedule) NextTime

func (it *Schedule) NextTime() int64

func (*Schedule) OnBoot

func (it *Schedule) OnBoot(opt bool) *Schedule

type Status

type Status struct {
}

Jump to

Keyboard shortcuts

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