recorder

package
v0.0.0-...-6ac6f58 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0, BSD-3-Clause, MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RecordKey

func RecordKey(command []string) string

RecordKey 提供一种生成record key的办法, 计算commands的md5

Types

type Record

type Record struct {
	Ignore bool   `json:"ignore" yaml:"ignore"`
	Key    string `json:"key" yaml:"key"`
	Name   string `json:"name" yaml:"name"`

	RetryAndSuccess int   `json:"retry_and_success" yaml:"retry_and_success"`
	SuggestTimeout  int   `json:"suggest_timeout" yaml:"suggest_timeout"`
	UpdateTime      int64 `json:"update_time" yaml:"update_time"`
	InspectTime     int64 `json:"inspect_time" yaml:"inspect_time"`
	// contains filtered or unexported fields
}

Record 记录单条job的历史记录

func (*Record) Clean

func (r *Record) Clean() error

Quit 将record数据从recorder中清除

func (*Record) Save

func (r *Record) Save() error

Save 保存当前的job记录到缓存中

type Recorder

type Recorder struct {
	Records []*Record `json:"records" yaml:"records"`
	// contains filtered or unexported fields
}

Recorder 用于记录work中命令的历史表现, 以支持相应的分发或执行决策 数据可以保存在文件中, 并支持加载已存在的文件

func NewRecorder

func NewRecorder(path string) (*Recorder, error)

NewRecorder get a new Recorder

func (*Recorder) Inspect

func (rr *Recorder) Inspect(key string) *Record

Inspect 通过key来定位记录, 获取记录信息 若record不在记录里, 先不要写入, 只有等到Save的时候才写入

func (*Recorder) Save

func (rr *Recorder) Save() error

Save 保存recorder数据到文件中

type RecordersPool

type RecordersPool struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

RecordersPool 提供一个池子来管理recorders, 可以用不同的key来区分不同的记录空间 例如以project为维度, 或以整台机器为维度

func NewRecordersPool

func NewRecordersPool() *RecordersPool

NewRecordersPool get a new RecordersPool

func (*RecordersPool) GetRecorder

func (rp *RecordersPool) GetRecorder(key string) (*Recorder, error)

GetRecorders 获取一个recorder, 若不在缓存中, 则从文件中读取或创建

func (*RecordersPool) SaveAll

func (rp *RecordersPool) SaveAll()

SaveAll 保存所有recorders到文件

Jump to

Keyboard shortcuts

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