Documentation ¶
Index ¶
Constants ¶
View Source
const (
Version = "0.1.1"
)
Variables ¶
Functions ¶
Types ¶
type Handler ¶
type Handler interface { // Handle 为 Runner 中循环执行的函数 Handle() // OnStart 在 Runner 启动前回调 OnStart() error // OnExit 在 Runner 退出前回调 OnExit() }
type IRunner ¶
type IRunner interface { // Start 启动 Runner Start() error // Stop 停止 Runner Stop() // KeepAlive 显式进行一次 keepalive KeepAlive() // IsTimeout 用于检查是否超时 IsTimeout(curTime time.Time) bool // Name 返回 Runner 命名 Name() string }
IRunner 包含 Runner 提供给外部的接口, 用于接口的继承
type NoopHandler ¶
type NoopHandler struct { }
func (*NoopHandler) Handle ¶
func (h *NoopHandler) Handle()
func (*NoopHandler) OnExit ¶
func (h *NoopHandler) OnExit()
func (*NoopHandler) OnStart ¶
func (h *NoopHandler) OnStart() error
type Runner ¶
type Runner struct { Timeout time.Duration Interval time.Duration Logger io.Writer // contains filtered or unexported fields }
Runner 是封装了永久循环的 goroutine 对象
func (*Runner) KeepAlive ¶
func (r *Runner) KeepAlive()
KeepAlive 刷新 LastHandleTime. 默认会在每次 handle 执行后执行
func (*Runner) LastHandleTime ¶
LastHandleTime 返回上一次 handle 执行结束的时间
Click to show internal directories.
Click to hide internal directories.