task_store

package
v0.0.0-...-298395c Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2019 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTaskExists       = errors.New("task already exists")
	ErrNoTaskExists     = errors.New("no task exists")
	ErrTemplateExists   = errors.New("template already exists")
	ErrNoTemplateExists = errors.New("no template exists")
	ErrNoSnapshotExists = errors.New("no snapshot exists")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// Deprecated, only needed to find old db and migrate
	Dir              string        `toml:"dir"`
	SnapshotInterval toml.Duration `toml:"snapshot-interval"`
}

func NewConfig

func NewConfig() Config

func (Config) Validate

func (c Config) Validate() error

type DBRP

type DBRP struct {
	Database        string
	RetentionPolicy string
}

type Diagnostic

type Diagnostic interface {
	StartingTask(taskID string)
	StartedTask(taskID string)

	FinishedTask(taskID string)

	Error(msg string, err error, ctx ...keyvalue.T)

	Debug(msg string)

	AlreadyMigrated(entity, id string)
	Migrated(entity, id string)
}

type Service

type Service struct {
	StorageService interface {
		Store(namespace string) storage.Interface
		Register(name string, store storage.StoreActioner)
	}
	HTTPDService interface {
		AddRoutes([]httpd.Route) error
		DelRoutes([]httpd.Route)
	}
	TaskMasterLookup interface {
		Main() *kapacitor.TaskMaster
		Get(string) *kapacitor.TaskMaster
		Set(*kapacitor.TaskMaster)
		Delete(*kapacitor.TaskMaster)
	}
	// contains filtered or unexported fields
}

func NewService

func NewService(conf Config, d Diagnostic) *Service

func (*Service) Close

func (ts *Service) Close() error

func (*Service) HasSnapshot

func (ts *Service) HasSnapshot(id string) bool

func (*Service) Load

func (ts *Service) Load(id string) (*kapacitor.Task, error)

func (*Service) LoadSnapshot

func (ts *Service) LoadSnapshot(id string) (*kapacitor.TaskSnapshot, error)

func (*Service) Open

func (ts *Service) Open() error

func (*Service) SaveSnapshot

func (ts *Service) SaveSnapshot(id string, snapshot *kapacitor.TaskSnapshot) error

type Snapshot

type Snapshot struct {
	NodeSnapshots map[string][]byte
}

type SnapshotDAO

type SnapshotDAO interface {
	// Load a saved snapshot.
	// ErrNoSnapshotExists will be returned if the snapshot does not exist.
	Get(id string) (*Snapshot, error)
	// Save a snapshot.
	Put(id string, snapshot *Snapshot) error
	// Delete a snapshot
	Delete(id string) error
	// Whether a snapshot exists in the store.
	Exists(id string) (bool, error)
}

Data access object for Snapshot data.

type Status

type Status int
const (
	Disabled Status = iota
	Enabled
)

type Task

type Task struct {
	// Unique identifier for the task
	ID string
	// The task type (stream|batch).
	Type TaskType
	// The DBs and RPs the task is allowed to access.
	DBRPs []DBRP
	// The TICKscript for the task.
	TICKscript string
	// ID of task template
	TemplateID string
	// Set of vars for a templated task
	Vars map[string]Var
	// Last error the task had either while defining or executing.
	Error string
	// Status of the task
	Status Status
	// Created Date
	Created time.Time
	// The time the task was last modified
	Modified time.Time
	// The time the task was last changed to status Enabled.
	LastEnabled time.Time
}

func (Task) MarshalBinary

func (t Task) MarshalBinary() ([]byte, error)

func (Task) ObjectID

func (t Task) ObjectID() string

func (*Task) UnmarshalBinary

func (t *Task) UnmarshalBinary(data []byte) error

type TaskDAO

type TaskDAO interface {
	// Retrieve a task
	Get(id string) (Task, error)

	// Create a task.
	// ErrTaskExists is returned if a task already exists with the same ID.
	Create(t Task) error

	// Replace an existing task.
	// ErrNoTaskExists is returned if the task does not exist.
	Replace(t Task) error

	// Delete a task.
	// It is not an error to delete an non-existent task.
	Delete(id string) error

	// List tasks matching a pattern.
	// The pattern is shell/glob matching see https://golang.org/pkg/path/#Match
	// Offset and limit are pagination bounds. Offset is inclusive starting at index 0.
	// More results may exist while the number of returned items is equal to limit.
	List(pattern string, offset, limit int) ([]Task, error)

	Rebuild() error
}

Data access object for Task data.

type TaskInfo

type TaskInfo struct {
	Name           string
	Type           kapacitor.TaskType
	DBRPs          []DBRP
	TICKscript     string
	Dot            string
	Enabled        bool
	Executing      bool
	Error          string
	ExecutionStats kapacitor.ExecutionStats
}

type TaskType

type TaskType int
const (
	StreamTask TaskType = iota
	BatchTask
	Undefined TaskType = -1
)

type Template

type Template struct {
	// Unique identifier for the task
	ID string
	// The task type (stream|batch).
	Type TaskType
	// The TICKscript for the task.
	TICKscript string
	// Last error the task had either while defining or executing.
	Error string
	// Created Date
	Created time.Time
	// The time the task was last modified
	Modified time.Time
}

type TemplateDAO

type TemplateDAO interface {
	// Retrieve a template
	Get(id string) (Template, error)

	// Create a template.
	// ErrTemplateExists is returned if a template already exists with the same ID.
	Create(t Template) error

	// Replace an existing template.
	// ErrNoTemplateExists is returned if the template does not exist.
	Replace(t Template) error

	// Delete a template.
	// It is not an error to delete an non-existent template.
	Delete(id string) error

	// List templates matching a pattern.
	// The pattern is shell/glob matching see https://golang.org/pkg/path/#Match
	// Offset and limit are pagination bounds. Offset is inclusive starting at index 0.
	// More results may exist while the number of returned items is equal to limit.
	List(pattern string, offset, limit int) ([]Template, error)

	// Associate a task with a template
	AssociateTask(templateId, taskId string) error

	// Disassociate a task with a template
	DisassociateTask(templateId, taskId string) error

	ListAssociatedTasks(templateId string) ([]string, error)
}

Data access object for Template data.

type Var

type Var struct {
	BoolValue     bool
	IntValue      int64
	FloatValue    float64
	StringValue   string
	RegexValue    string
	DurationValue time.Duration
	LambdaValue   string
	ListValue     []Var

	Type        VarType
	Description string
}

type VarType

type VarType int
const (
	VarUnknown VarType = iota
	VarBool
	VarInt
	VarFloat
	VarString
	VarRegex
	VarDuration
	VarLambda
	VarList
	VarStar
)

func (VarType) String

func (vt VarType) String() string

Jump to

Keyboard shortcuts

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