loader

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Loader

type Loader interface {
	// LoadConfig load the task config
	LoadConfig() (*TaskConfig, error)
	// LoadContent load the specified task item content
	LoadContent(conf string) (string, error)
	// SaveConfig save the task config
	SaveConfig(c *TaskConfig) error
	// SaveContent save the specified task item content
	SaveContent(conf string, content string) error
	// Close release the dependent resource
	Close() error
}

Loader a task config loader interface

func NewLoader

func NewLoader(path string) (Loader, error)

NewLoader return a task config loader instance and currently support file, memory, redis, buntdb memory, buntdb, etcd. Examples like the following: file://task.yaml memory: redis://127.0.0.1:6379 buntdb://:memory: or buntdb://buntdb.db etcd://127.0.0.1:2379?dial_timeout=5s

type TaskConfig

type TaskConfig struct {
	// Tasks the task list
	Tasks []*TaskItem `json:"tasks" yaml:"tasks"`
}

TaskConfig the config of tasks

type TaskItem

type TaskItem struct {
	// Name a unique task name
	Name string `json:"name" yaml:"name"`
	// Conf the source of task config
	Conf string `json:"conf" yaml:"conf"`
	// Labels it can only acquire the current task if the client matches all the labels
	Labels []string `json:"labels" yaml:"labels"`
	// AllowIP the current task only allows the specified ip to access
	AllowIP []string `json:"allow_ip" yaml:"allow_ip"`
}

TaskItem a task item

Jump to

Keyboard shortcuts

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