vust

package module
v0.0.0-...-c2d2de8 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2025 License: MIT Imports: 9 Imported by: 0

README

Vust

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Batch

type Batch struct {
	ID    int
	Items []any
}

type DefaultErrorListener

type DefaultErrorListener struct{}

func (*DefaultErrorListener) OnProcess

func (l *DefaultErrorListener) OnProcess(ctx StepContext, log *logrus.Logger, item any, err error)

func (*DefaultErrorListener) OnRead

func (l *DefaultErrorListener) OnRead(ctx StepContext, log *logrus.Logger, err error)

func (*DefaultErrorListener) OnWrite

func (l *DefaultErrorListener) OnWrite(ctx StepContext, log *logrus.Logger, batch *Batch, err error)

type DefaultJobListener

type DefaultJobListener struct{}

func (*DefaultJobListener) After

func (l *DefaultJobListener) After(ctx JobContext, log *logrus.Logger)

func (*DefaultJobListener) Before

func (l *DefaultJobListener) Before(ctx JobContext, log *logrus.Logger)

type ErrorListener

type ErrorListener interface {
	OnRead(ctx StepContext, log *logrus.Logger, err error)
	OnProcess(ctx StepContext, log *logrus.Logger, item any, err error)
	OnWrite(ctx StepContext, log *logrus.Logger, batch *Batch, err error)
}

func NewDefaultErrorListener

func NewDefaultErrorListener() ErrorListener

type ItemProcessor

type ItemProcessor interface {
	Process(ctx StepContext, log *logrus.Logger, item any) (any, error)
}

type ItemReader

type ItemReader interface {
	Read(ctx StepContext, log *logrus.Logger) (any, error)
}

type ItemWriter

type ItemWriter interface {
	Write(ctx StepContext, log *logrus.Logger, batch *Batch) error
}

type Job

type Job interface {
	WithContext(JobContext) Job
	SetLogger(*logrus.Logger) Job
	AddStep(Step) Job
	Run() error
}

func New

func New(config ...JobConfig) Job

type JobConfig

type JobConfig struct {
	Name        string
	JobListener JobListener
}

type JobContext

type JobContext interface {
	context.Context

	Keys() []string
	Get(key string) (any, bool)
	GetString(key string, def ...string) string
	GetInt(key string, def ...int) int
	GetFloat(key string, def ...float64) float64
	GetBool(key string, def ...bool) bool
	GetTime(key string, def ...time.Time) time.Time
	GetDuration(key string, def ...time.Duration) time.Duration
	Set(key string, value any)
	Delete(key string)

	WithCancel() (JobContext, context.CancelFunc)
	WithTimeout(d time.Duration) (JobContext, context.CancelFunc)
	WithDeadline(t time.Time) (JobContext, context.CancelFunc)
}

func NewJobContext

func NewJobContext(ctx context.Context) JobContext

type JobListener

type JobListener interface {
	Before(ctx JobContext, log *logrus.Logger)
	After(ctx JobContext, log *logrus.Logger)
}

func NewDefaultJobListener

func NewDefaultJobListener() JobListener

type JobPrefixHook

type JobPrefixHook struct {
	Name string
}

func (*JobPrefixHook) Fire

func (h *JobPrefixHook) Fire(entry *logrus.Entry) error

func (*JobPrefixHook) Levels

func (h *JobPrefixHook) Levels() []logrus.Level

type ModulePrefixHook

type ModulePrefixHook struct{}

func (*ModulePrefixHook) Fire

func (h *ModulePrefixHook) Fire(entry *logrus.Entry) error

func (*ModulePrefixHook) Levels

func (h *ModulePrefixHook) Levels() []logrus.Level

type Step

type Step interface {
	WithContext(StepContext) Step
	SetLogger(*logrus.Logger) Step
	SetJobName(name string) Step
	Run() error
}

func NewStep

func NewStep(config ...StepConfig) Step

type StepConfig

type StepConfig struct {
	Name          string
	Reader        ItemReader
	Processor     ItemProcessor
	Writer        ItemWriter
	ChunkSize     int
	ErrorListener ErrorListener
}

type StepContext

type StepContext interface {
	context.Context

	JobContext() JobContext
	Keys() []string
	Get(key string) (any, bool)
	GetString(key string, def ...string) string
	GetInt(key string, def ...int) int
	GetFloat(key string, def ...float64) float64
	GetBool(key string, def ...bool) bool
	GetTime(key string, def ...time.Time) time.Time
	GetDuration(key string, def ...time.Duration) time.Duration
	Set(key string, value any)
	Delete(key string)

	WithCancel() (StepContext, context.CancelFunc)
	WithTimeout(d time.Duration) (StepContext, context.CancelFunc)
	WithDeadline(t time.Time) (StepContext, context.CancelFunc)
}

func NewStepContext

func NewStepContext(jobContext JobContext) StepContext

type StepPrefixHook

type StepPrefixHook struct {
	Name string
}

func (*StepPrefixHook) Fire

func (h *StepPrefixHook) Fire(entry *logrus.Entry) error

func (*StepPrefixHook) Levels

func (h *StepPrefixHook) Levels() []logrus.Level

Jump to

Keyboard shortcuts

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