task_store

package
v1.4.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2017 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 added in v0.13.0

type DBRP struct {
	Database        string
	RetentionPolicy string
}

type Diagnostic added in v1.4.0

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 added in v0.10.0

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

func (*Service) Load

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

func (*Service) LoadSnapshot added in v0.10.0

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

func (*Service) Open

func (ts *Service) Open() error

func (*Service) SaveSnapshot added in v0.10.0

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

type Snapshot added in v0.13.0

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

type SnapshotDAO added in v0.13.0

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 added in v0.13.0

type Status int
const (
	Disabled Status = iota
	Enabled
)

type Task added in v0.13.0

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 added in v1.2.0

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

func (Task) ObjectID added in v1.2.0

func (t Task) ObjectID() string

func (*Task) UnmarshalBinary added in v1.2.0

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

type TaskDAO added in v0.13.0

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 added in v0.13.0

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

type Template added in v1.0.0

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 added in v1.0.0

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 added in v1.0.0

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 added in v1.0.0

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

func (VarType) String added in v1.0.0

func (vt VarType) String() string

Jump to

Keyboard shortcuts

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