schedules

package
v0.0.0-...-d2438c5 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const Interval = 20

Interval represents the number of seconds to wait between each schedule iteration

Variables

This section is empty.

Functions

This section is empty.

Types

type Batch

type Batch struct {
	Results []Result `json:"results" yaml:"results"`
	Err     string   `json:"err" yaml:"err"`
}

Batch holds all the query results for a singular query

type Cluster

type Cluster interface {
	database.DBAccessor
	db.ClusterOpener
	db.ClusterTransactioner
	db.ClusterExclusiveLocker

	// NodeID sets the the node NodeID associated with this cluster instance. It's used for
	// backward-compatibility of all db-related APIs that were written before
	// clustering and don't accept a node NodeID, so in those cases we automatically
	// use this value as implicit node NodeID.
	NodeID(int64)

	// SchemaVersion returns the underlying schema version for the cluster
	SchemaVersion() int

	// Close the database facade.
	Close() error
}

Cluster mediates access to data stored in the cluster dqlite database.

type Daemon

type Daemon interface {
	// Gateway returns the underlying Daemon Gateway
	Gateway() Gateway

	// Cluster returns the underlying Cluster
	Cluster() Cluster

	// Node returns the underlying Node associated with the daemon
	Node() Node

	// NodeConfigSchema returns the daemon schema for the local Node
	NodeConfigSchema() config.Schema
}

Daemon can respond to requests from a shared client.

type Gateway

type Gateway interface {

	// IsDatabaseNode returns true if this gateway also run acts a raft database
	// node.
	IsDatabaseNode() bool

	// LeaderAddress returns the address of the current raft leader.
	LeaderAddress() (string, error)
}

Gateway mediates access to the dqlite cluster using a gRPC SQL client, and possibly runs a dqlite replica on this node (if we're configured to do so).

type Node

type Node interface {
	database.DBAccessor
	db.NodeOpener
	db.NodeTransactioner

	// Dir returns the directory of the underlying database file.
	Dir() string

	// Close the database facade.
	Close() error
}

Node mediates access to the data stored locally

type Option

type Option func(*options)

Option to be passed to Connect to customize the resulting instance.

func WithClock

func WithClock(clock clock.Clock) Option

WithClock sets the clock on the option

func WithLogger

func WithLogger(logger log.Logger) Option

WithLogger sets the logger on the option

type Result

type Result struct {
	Type         string          `json:"type" yaml:"type"`
	Columns      []string        `json:"columns" yaml:"columns"`
	Rows         [][]interface{} `json:"rows" yaml:"rows"`
	RowsAffected int64           `json:"rows_affected" yaml:"rows_affected"`
}

Result holds the query result for a singular query

type Schedules

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

Schedules represents a task collection of things that want to be run

func New

func New(daemon Daemon, options ...Option) *Schedules

New creates a series of tasks to be worked on

func (*Schedules) Add

func (s *Schedules) Add(tsk *Task) error

Add an task to the collection

func (*Schedules) GetTsk

func (s *Schedules) GetTsk(id string) (Tsk, error)

GetTsk returns a scheduled task

func (*Schedules) Remove

func (s *Schedules) Remove(id string) error

Remove an task from the collection

func (*Schedules) Run

func (s *Schedules) Run() (task.Func, task.Schedule)

Run returns a task function that performs operational GC checks against the internal cache of operations.

func (*Schedules) Walk

func (s *Schedules) Walk(fn func(Tsk) error) error

Walk over the operations in a predictable manor

type Status

type Status int

Status defines all the state a schedule task can be in

const (
	// Pending status operation
	Pending Status = iota
	// Running status operation
	Running
	// Failure status operation
	Failure
	// Success status operation
	Success
)

func (Status) IsFinal

func (s Status) IsFinal() bool

IsFinal will return true if the status code indicates an end state

func (Status) Raw

func (s Status) Raw() int

Raw returns the underlying value

func (Status) String

func (s Status) String() string

type Task

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

Task defines an operation to be run at a given schedule

func NewTask

func NewTask(id, query string, schedule time.Time, options ...Option) *Task

NewTask creates an operation with sane defaults

func (*Task) Render

func (t *Task) Render() Tsk

Render the task as a readonly Tsk

type Tsk

type Tsk struct {
	ID         string
	Query      string
	Schedule   time.Time
	Status     string
	StatusCode Status
	URL        string
	Result     string
	Err        string
}

Tsk defines a very lightweight task

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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