server

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2019 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BucketNameForJobs = "j"
)

Variables

View Source
var (
	DefaultJobName = "default"
)
View Source
var (
	WorkerDefaultUserAgent = fmt.Sprintf("%s/%s", hq.DisplayName, hq.Version)
)

Functions

func AppContextMiddleware

func AppContextMiddleware(app *App) echo.MiddlewareFunc

func CreateJobHandler

func CreateJobHandler(c echo.Context) error

func DeleteJobHandler

func DeleteJobHandler(c echo.Context) error

func ErrorHandler

func ErrorHandler(err error, c echo.Context)

func GetJobHandler

func GetJobHandler(c echo.Context) error

func InfoHandler

func InfoHandler(c echo.Context) error

func ListJobsHandler

func ListJobsHandler(c echo.Context) error

func NewErrorValidationFailed

func NewErrorValidationFailed(msgs ...string) *echo.HTTPError

NewErrorResponseWithValidatorReport creates new error response with ValidationReport.

func NewHttpErrorNotFound

func NewHttpErrorNotFound(msgs ...string) *echo.HTTPError

func RestartJobHandler

func RestartJobHandler(c echo.Context) error

func StatsHandler

func StatsHandler(c echo.Context) error

func StopJobHandler

func StopJobHandler(c echo.Context) error

func UIFallbackHandler

func UIFallbackHandler(c echo.Context) error

func UIIndexHandler

func UIIndexHandler(c echo.Context) error

Types

type App

type App struct {
	// Configuration of the application instance
	Config *Config
	// Logger
	Logger echo.Logger
	// LogfileWriter
	LogfileWriter reopen.Writer
	// LogLevel
	LogLevel log.Lvl
	// Echo web framework
	Echo *echo.Echo
	// AccessLog
	AccessLogFile *os.File
	// AccessLogFile
	AccessLogFileWriter reopen.Writer
	// DataDir
	DataDir string
	// UseTempDataDir
	UseTempDataDir bool
	// DB
	DB *bolt.DB
	// Store
	Store *Store
	// Background
	Background *Background
	// katsubushi
	Gen katsubushi.Generator
	// QueueManager
	QueueManager *QueueManager
}

func NewApp

func NewApp(config ...*Config) *App

func (*App) BoltDBPath

func (app *App) BoltDBPath() string

func (*App) Close

func (app *App) Close() error

func (*App) ListenAndServe

func (app *App) ListenAndServe() error

func (*App) Open

func (app *App) Open() error

type AppContext

type AppContext struct {
	echo.Context
	// contains filtered or unexported fields
}

func (*AppContext) App

func (c *AppContext) App() *App

type Background

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

func NewBackground

func NewBackground(app *App) *Background

func (*Background) Close

func (bg *Background) Close()

func (*Background) Start

func (bg *Background) Start()

type Config

type Config struct {
	ServerId            uint   `toml:"server_id"`
	LogLevel            string `toml:"log_level"`
	Addr                string `toml:"addr"`
	Logfile             string `toml:"log_file"`
	DataDir             string `toml:"data_dir"`
	AccessLogfile       string `toml:"access_log_file"`
	Queues              int64  `toml:"queues"`
	Dispatchers         int64  `toml:"dispatchers"`
	MaxWorkers          int64  `toml:"max_workers"`
	ShutdownTimeout     int64  `toml:"shutdown_timeout"`
	JobLifetime         int64  `toml:"job_lifetime"`
	JobListDefaultLimit int    `toml:"job_list_default_limit"`
	UI                  bool   `toml:"ui"`
	UIBasename          string `toml:"ui_basename"`
	IDEpoch             []int  `toml:"id_epoch"`
}

func NewConfig

func NewConfig() *Config

func (*Config) IDEpochTime

func (c *Config) IDEpochTime() (time.Time, error)

func (*Config) LoadConfigFile

func (c *Config) LoadConfigFile(path string) error

func (*Config) SetLogLevel

func (c *Config) SetLogLevel(level string)

type Dispatcher

type Dispatcher struct {
	NumWorkers int64
	// contains filtered or unexported fields
}

type ErrJobAlreadyExisted

type ErrJobAlreadyExisted struct {
	ID   uint64
	Name string
}

func (*ErrJobAlreadyExisted) Error

func (e *ErrJobAlreadyExisted) Error() string

type ErrJobNotFound

type ErrJobNotFound struct {
	ID uint64
}

func (*ErrJobNotFound) Error

func (e *ErrJobNotFound) Error() string

type J

type J struct {
	ID         uint64
	Name       string
	Comment    string
	URL        string
	Payload    json.RawMessage
	Headers    map[string]string
	Timeout    int64
	CreatedAt  time.Time
	StartedAt  *time.Time
	FinishedAt *time.Time
	Failure    bool
	Success    bool
	Canceled   bool
	StatusCode *int
	Err        string
	Output     string
}

J is internal representation of a job in the boltdb.

type ListJobsQuery

type ListJobsQuery struct {
	Name    string
	Term    string
	Begin   *uint64
	Reverse bool
	Limit   int
	Status  string
}

type QueueManager

type QueueManager struct {
	App         *App
	Queue       chan *hq.Job
	Dispatchers []*Dispatcher
	WorkerWg    *sync.WaitGroup

	WaitingJobs map[uint64]*WaitingJob
	RunningJobs map[uint64]*RunningJob
	// contains filtered or unexported fields
}

func NewQueueManager

func NewQueueManager(app *App) *QueueManager

func (*QueueManager) CancelJob

func (m *QueueManager) CancelJob(id uint64) error

func (*QueueManager) EnqueueAsync

func (m *QueueManager) EnqueueAsync(job *hq.Job)

func (*QueueManager) RegisterRunningJob

func (m *QueueManager) RegisterRunningJob(job *hq.Job, cancel context.CancelFunc)

func (*QueueManager) RegisterWaitingJob

func (m *QueueManager) RegisterWaitingJob(job *hq.Job)

func (*QueueManager) RemoveRunningJob

func (m *QueueManager) RemoveRunningJob(job *hq.Job)

func (*QueueManager) Start

func (m *QueueManager) Start()

func (*QueueManager) UpdateJobStatus

func (m *QueueManager) UpdateJobStatus(job *hq.Job) *hq.Job

func (*QueueManager) Wait

func (m *QueueManager) Wait()

type RunningJob

type RunningJob struct {
	Job    *hq.Job
	Cancel context.CancelFunc
}

type Store

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

func (*Store) CreateJob

func (s *Store) CreateJob(job *hq.Job) error

func (*Store) DeleteJob

func (s *Store) DeleteJob(id uint64) error

func (*Store) FetchJob

func (s *Store) FetchJob(id uint64, job *hq.Job) error

func (*Store) Init

func (s *Store) Init() error

func (*Store) JobsStats

func (s *Store) JobsStats() (*bolt.BucketStats, error)

func (*Store) ListJobs

func (s *Store) ListJobs(query *ListJobsQuery, ret *hq.JobList) error

func (*Store) UpdateJob

func (s *Store) UpdateJob(job *hq.Job) error

type Template

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

func NewTemplate

func NewTemplate(app *App) *Template

func (*Template) Render

func (t *Template) Render(w io.Writer, name string, data interface{}, c echo.Context) error

type WaitingJob

type WaitingJob struct {
	Job *hq.Job
}

Jump to

Keyboard shortcuts

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