job

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: MIT Imports: 13 Imported by: 0

README

xxl-job

基于 XXL-Job 封装的 go-sdk, 提供了 proto 定义,建议直接引入

在 kratos 配置文件 conf.proto 中引入 api/job/job.proto 并写入到 Bootstrap 结构体中 重新生成配置文件,即可加载 xxl-job 的配置文件内容

支持传递 go-kratos 的 http.Server 为其提供任务注册端口复用

Documentation

Overview

只为了测试xxljob配合链路追踪的日志输出,将zap封装成kratos log

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Enabled      bool
	ServerAddr   string
	AccessToken  string
	Timeout      *durationpb.Duration
	ExecutorIp   string
	ExecutorPort int32
	RegistryKey  string
}

func (*Config) GetAccessToken

func (c *Config) GetAccessToken() string

func (*Config) GetEnabled

func (c *Config) GetEnabled() bool

func (*Config) GetExecutorIp

func (c *Config) GetExecutorIp() string

func (*Config) GetExecutorPort

func (c *Config) GetExecutorPort() int32

func (*Config) GetRegistryKey

func (c *Config) GetRegistryKey() string

func (*Config) GetServerAddr

func (c *Config) GetServerAddr() string

func (*Config) GetTimeout

func (c *Config) GetTimeout() *durationpb.Duration

type JobConfig

type JobConfig interface {
	GetEnabled() bool
	GetServerAddr() string
	GetAccessToken() string
	GetTimeout() *durationpb.Duration
	GetExecutorIp() string
	GetExecutorPort() int32
	GetRegistryKey() string
}

type JobExecutor

type JobExecutor struct {
	// contains filtered or unexported fields
}

func NewJobExecutor

func NewJobExecutor(logger log.Logger, conf JobConfig, httpServer *http.Server) *JobExecutor

func NewJobExecutorWithTracer

func NewJobExecutorWithTracer(logger log.Logger, conf JobConfig, httpServer *http.Server) *JobExecutor

func (*JobExecutor) RegisterTask

func (r *JobExecutor) RegisterTask(pattern string, fn JobFunc)

func (*JobExecutor) Start

func (r *JobExecutor) Start(ctx context.Context) error

func (*JobExecutor) Stop

func (r *JobExecutor) Stop(ctx context.Context) error

type JobFunc

type JobFunc func(ctx context.Context, payload string) (string, error)

JobFunc (ctx, JSONString)

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

func NewLogger

func NewLogger(zlog *zap.Logger) *Logger

func (*Logger) Close

func (l *Logger) Close() error

func (*Logger) Log

func (l *Logger) Log(level log.Level, keyvals ...interface{}) error

func (*Logger) Sync

func (l *Logger) Sync() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳