web

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2021 License: Apache-2.0 Imports: 26 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init()

Init initializes global parameters of the Web server by configuration values.

Types

type Application

type Application struct {
	AccessLogWriter   io.Writer
	Version           string
	Service           Service
	QueueRepository   repository.QueueRepository
	RoutingRepository repository.RoutingRepository
}

Application is an interface of the application.

func (*Application) Serve

func (app *Application) Serve()

Serve starts the application Web server.

type DispatcherStats added in v1.0.2

type DispatcherStats = *dispatcher.Stats

DispatcherStats is an alias to pointer type of dispatcher.Stats.

type IncomingJob

type IncomingJob struct {
	CategoryField string          `json:"category"`
	URLField      string          `json:"url"`
	PayloadField  json.RawMessage `json:"payload"`

	RunAfterField   uint `json:"run_after"`   // seconds
	TimeoutField    uint `json:"timeout"`     // seconds
	RetryDelayField uint `json:"retry_delay"` // seconds
	MaxRetriesField uint `json:"max_retries"`
	// contains filtered or unexported fields
}

IncomingJob describes a job to be pushed in a queue.

func (*IncomingJob) Category

func (job *IncomingJob) Category() string

Category returns the category of the job.

func (*IncomingJob) DecodePayload

func (job *IncomingJob) DecodePayload() error

DecodePayload decodes PayloadField of the job.

If PayloadField starts and ends with ", then it is decoded as a JSON string. If PayloadField is "null" then it is decoded to an empty string. Otherwise, the decoded value is the raw string of PayloadField.

The decoded value can be retrieved by Payload() method.

func (*IncomingJob) NextDelay

func (job *IncomingJob) NextDelay() uint64

NextDelay returns the delay for a next try of the job.

func (*IncomingJob) Payload

func (job *IncomingJob) Payload() string

Payload returns a decoded value of PayloadField.

func (*IncomingJob) RetryCount

func (job *IncomingJob) RetryCount() uint

RetryCount returns the max retries of the job.

func (*IncomingJob) RetryDelay

func (job *IncomingJob) RetryDelay() uint

RetryDelay returns the delay for retries of the job.

func (*IncomingJob) Timeout

func (job *IncomingJob) Timeout() uint

Timeout returns the timeout of the job.

func (*IncomingJob) URL

func (job *IncomingJob) URL() string

URL returns the URL of the job.

type JobqueueStats added in v1.0.2

type JobqueueStats = *jobqueue.Stats

JobqueueStats is an alias to pointer type of jobqueue.Stats.

type PushResult

type PushResult struct {
	ID        uint64 `json:"id"`
	QueueName string `json:"queue_name"`
	IncomingJob
}

PushResult describes a job pushed to a queue.

type Service

type Service interface {
	Stop() <-chan struct{}
	GetJobQueue(qn string) (service.RunningQueue, bool)
	DeleteJobQueue(qn string) error
	AddJobQueue(q *model.Queue) error
	Push(job jobqueue.IncomingJob) (*service.PushResult, error)
}

Service is an interface of the application use case service.

type Stats

type Stats struct {
	JobqueueStats
	DispatcherStats
	ActiveNodes int64 `json:"active_nodes"`
}

Stats contains queue statistics and worker statistics.

Jump to

Keyboard shortcuts

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