storage

package
v0.0.0-...-9021772 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QueueDingding = "dingding"
	QueueFileSync = "file-sync"
)
View Source
const (
	GlobalNamespace   = "global"
	SyncActionSetting = "sync-action"
)
View Source
const (
	MessageErrorType = "errors"
)
View Source
const StatusKeepDuration int64 = 24 * 3600

StatusKeepDuration 状态保存有效期

Variables

View Source
var ErrNoSuchDefinition = errors.New("no such definition")

ErrNoSuchDefinition 没有找到指定的定义

View Source
var ErrNoSuchJob = errors.New("no such job")
View Source
var ErrNoSuchSetting = errors.New("no such setting")
View Source
var ErrQueueTimeout = errors.New("timeout")

ErrQueueTimeout 队列超时

Functions

func NewSettingFactory

func NewSettingFactory(db *ledis.DB) *settingFactory

Types

type DefinitionStore

type DefinitionStore interface {
	Update(def meta.FileSyncGroup) error
	Delete(name string) error
	Get(name string) (*meta.FileSyncGroup, error)
	All() ([]meta.FileSyncGroup, error)
}

DefinitionStore 同步定义存储接口

func NewDefinitionStore

func NewDefinitionStore(db *ledis.DB) DefinitionStore

type FailedJobStore

type FailedJobStore interface {
	Add(id string, data []byte) error
	All() ([][]byte, error)
	Get(id string) ([]byte, error)
	Delete(id string) error
}

func NewFailedJobStore

func NewFailedJobStore(db *ledis.DB) FailedJobStore

type JobHistoryItem

type JobHistoryItem struct {
	ID        string    `json:"id"`
	JobID     string    `json:"job_id"`
	Name      string    `json:"name"`
	Payload   []byte    `json:"payload"`
	Output    []byte    `json:"output"`
	Status    string    `json:"status"`
	CreatedAt time.Time `json:"created_at"`
}

type JobHistoryStore

type JobHistoryStore interface {
	// Record 记录 JOB 执行历史
	Record(item JobHistoryItem) error
	// Recently 返回最近的 limit 条记录
	Recently(limit int) ([]JobHistoryItem, error)
	// Truncate 清空历史纪录
	Truncate() error
	// Keep 只保留指定数量的最新记录
	Keep(keepCount int64) error
}

func NewJobHistoryStore

func NewJobHistoryStore(db *ledis.DB) JobHistoryStore

type JobStatus

type JobStatus string

JobStatus 任务状态

const (
	JobStatusPending  JobStatus = "pending"
	JobStatusRunning  JobStatus = "running"
	JobStatusUnstable JobStatus = "unstable"
	JobStatusFailed   JobStatus = "failed"
	JobStatusOK       JobStatus = "ok"
)

type JobStatusStore

type JobStatusStore interface {
	// Status 任务执行状态查询
	Status(id string) JobStatus
	// LastStatus return last changed status for a sync definition
	LastStatus(name string) (JobStatus, time.Time)
	// 更新任务执行状态
	Update(id string, name string, status JobStatus) error
}

JobStatusStore 任务执行状态查询

func NewJobStatusStore

func NewJobStatusStore(db *ledis.DB) JobStatusStore

type MessageFactory

type MessageFactory interface {
	MessageStore(name string) MessageStore
}

func NewMessageFactory

func NewMessageFactory(db *ledis.DB) MessageFactory

type MessageStore

type MessageStore interface {
	// Record 记录
	Record(item string) error
	// Recently 返回最近的 limit 条记录
	Recently(limit int) ([]string, error)
	// Truncate 清空历史纪录
	Truncate() error
	// Keep 只保留指定数量的最新记录
	Keep(keepCount int64) error
}

type QueueStore

type QueueStore interface {
	// Enqueue 加入队列
	Enqueue(payload []byte) error
	// Dequeue 从队列中读取
	// timeout > 0 则使用堵塞队列
	Dequeue(timeout time.Duration) ([]byte, error)
	// All 返回队列中所有任务
	All() ([][]byte, error)
}

QueueStore 队列接口

func NewLedisQueueStore

func NewLedisQueueStore(db *ledis.DB, name string) QueueStore

NewLedisQueueStore 创建一个 Ledis 队列

type QueueStoreFactory

type QueueStoreFactory interface {
	// QueueStore 获取队列实例
	Queue(name string) QueueStore
}

QueueStoreFactory 队列工厂接口

func NewQueueStoreFactory

func NewQueueStoreFactory(db *ledis.DB) QueueStoreFactory

NewQueueStoreFactory 创建一个队列工厂实例

type ServiceProvider

type ServiceProvider struct{}

func (*ServiceProvider) Boot

func (s *ServiceProvider) Boot(app *glacier.Glacier)

func (*ServiceProvider) Register

func (s *ServiceProvider) Register(app *container.Container)

type SettingFactory

type SettingFactory interface {
	Namespace(namespace string) SettingStore
}

SettingFactory is a factory for creating settingStore

type SettingStore

type SettingStore interface {
	Update(key string, payload []byte) error
	Get(key string) ([]byte, error)
}

SettingStore is a store for settings

Jump to

Keyboard shortcuts

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