syncrunner

package
v0.0.0-...-cf16bd4 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2022 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// EnvCFAPIKey api key 环境变量 key
	EnvCFAPIKey = "CF_API_KEY"
	// EnvCFAPIEmail api email 环境变量 key
	EnvCFAPIEmail = "CF_API_EMAIL"
)

Variables

View Source
var (
	// ErrNotSetEnv 未设置环境变量
	ErrNotSetEnv = errors.New("cf env not set")
	// ErrNotSetTask 未设置工作模式
	ErrNotSetTask = errors.New("cf task not set")
)

Functions

This section is empty.

Types

type ErrCallback

type ErrCallback func(err error)

ErrCallback 错误处理回调, err 为 nil 时代表成功

type RunTask

type RunTask interface {
	ZoneName() string // 域名
	AName() string    // a记录名字
}

RunTask 工作模式

func NewStaticTask

func NewStaticTask(zoneName, aName string) RunTask

type Runner

type Runner struct {
	APIKey   string
	APIEmail string
	// contains filtered or unexported fields
}

Runner 执行者定义

func NewRunner

func NewRunner() (*Runner, error)

NewRunner 初始化 Runner, 从环境变量读取配置

func NewRunnerWithInfo

func NewRunnerWithInfo(apiKey, apiEmail string) *Runner

NewRunnerWithInfo 初始化 Runner

func (*Runner) PrepareCron

func (r *Runner) PrepareCron(spec string, first bool, callback ErrCallback) *cron.Cron

PrepareCron 准备 cron 执行

func (*Runner) Run

func (r *Runner) Run(ctx context.Context) error

Run 执行一次

func (*Runner) SetTask

func (r *Runner) SetTask(task RunTask)

SetTask 设置工作模式

Jump to

Keyboard shortcuts

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