delayTask_etcd

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2024 License: MIT Imports: 11 Imported by: 0

README

delayTask-etcd

Go语言基于ETCD的Watch机制的延时任务库,延时任务通过闭包异步调用,可选支持心跳检测重连。

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DelayTask

type DelayTask interface {

	/*
			SetDelayTask:开始一个延时任务 延时时间到达异步触发设置的回调函数
		                  该设置为覆盖设置,将会重新租约并且替换回调
	*/
	SetDelayTask(key string, f func(), ttl int64) error

	/*
		CancelDelayTask :取消延时任务
	*/
	CancelDelayTask(key string) error

	/*
		Close: 取消监听延时任务退出
	*/
	Close() error
}

func NewEtcdDelayTask

func NewEtcdDelayTask(cli *clientv3.Client, prefix string, opts ...Option) (DelayTask, error)

type ErrMsg

type ErrMsg string
const ClosedErr ErrMsg = "etcdDelayTask had been closed"

func (ErrMsg) Error

func (e ErrMsg) Error() string

type Logger

type Logger interface {
	Info(format string, v ...interface{})
	Error(format string, v ...interface{})
}

type NewEtcdClientFunc

type NewEtcdClientFunc func() (*clientv3.Client, error)

type Option

type Option func(*etcdDelayTask)

func WithEtcdHeartbeat

func WithEtcdHeartbeat(newFunc NewEtcdClientFunc) Option

func WithEtcdTimeout

func WithEtcdTimeout(timeout time.Duration) Option

func WithLogger

func WithLogger() Option

func WithLoggerWrapper

func WithLoggerWrapper(log Logger) Option

func WithReConnectCallback

func WithReConnectCallback(f func()) Option

func WithReConnectEtcdTimeout

func WithReConnectEtcdTimeout(timeout time.Duration) Option

Jump to

Keyboard shortcuts

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