Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 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 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) Levels ¶
func (h *JobPrefixHook) Levels() []logrus.Level
type ModulePrefixHook ¶
type ModulePrefixHook struct{}
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) Levels ¶
func (h *StepPrefixHook) Levels() []logrus.Level
Click to show internal directories.
Click to hide internal directories.