Documentation
¶
Index ¶
- Constants
- Variables
- func Debug(v ...interface{})
- func Debugf(format string, v ...interface{})
- func Error(v ...interface{})
- func Errorf(format string, v ...interface{})
- func Fatal(v ...interface{})
- func Fatalf(format string, v ...interface{})
- func GetConfigBytes(key string) ([]byte, error)
- func Info(v ...interface{})
- func Infof(format string, v ...interface{})
- func NewPipeTask(task Task, runAfter ...string) *pipeTask
- func Panic(v ...interface{})
- func Panicf(format string, v ...interface{})
- func Run(ctx context.Context, param Parameter) (err error)
- func SetConfig(key string, c Config) error
- func Warn(v ...interface{})
- func Warnf(format string, v ...interface{})
- type Config
- type ErrorTao
- type ErrorUnWrapper
- type LogLevel
- type Logger
- type Parameter
- type Pipeline
- type PipelineOption
- type TaoConfig
- type Task
- type TaskOption
- type TaskRun
- type TaskState
Constants ¶
View Source
const ( Unknown = "Unknown" ParamInvalid = "ParamInvalid" ContextCanceled = "ContextCanceled" DuplicateCall = "DuplicateCall" TaskRunTwice = "TaskRunTwice" TaskCloseTwice = "TaskCloseTwice" TaskClosed = "TaskClosed" TaskRunning = "TaskRunning" ConfigNotFound = "ConfigNotFound" )
* ErrorCode
View Source
const ConfigKey = "tao"
ConfigKey for this repo
Variables ¶
View Source
var LevelPrefix = map[LogLevel]string{ DEBUG: "[D] ", INFO: "[I] ", WARNING: "[W] ", ERROR: "[E] ", PANIC: "[P] ", FATAL: "[F] ", }
LevelPrefix to define log prefix of log level
View Source
var TaoLevel = DEBUG
TaoLevel to define the log level of tao
View Source
var TaoWriter io.Writer
TaoWriter for TaoLogger
Functions ¶
func GetConfigBytes ¶
GetConfigBytes by key of config
func NewPipeTask ¶
NewPipeTask constructor of pipeTask
Types ¶
type Config ¶
type Config interface {
// Default config
Default() Config
// ValidSelf with some default values
ValidSelf()
// ToTask transform itself to Task
ToTask() Task
// RunAfter defines pre task names
RunAfter() []string
}
Config interface
type ErrorUnWrapper ¶
ErrorUnWrapper extension of error
func NewErrorUnWrapper ¶
func NewErrorUnWrapper(format string, e error) ErrorUnWrapper
NewErrorUnWrapper constructor of errorUnWrap
type LogLevel ¶
type LogLevel uint8
LogLevel log's level
const ( // DEBUG (usually) is used in development env to print track info but disabled in production env to avoid overweight logs DEBUG LogLevel = iota // INFO (usually) is default level to print some core infos INFO // WARNING should be mentioned, it's more important than INFO WARNING // ERROR must be solved, program shouldn't generate any error-level logs. ERROR // PANIC logs a message, then panics. PANIC // FATAL logs a message, then calls os.Exit(1). FATAL )
type Logger ¶
type Logger interface {
Debug(calldepth int, v ...interface{})
Debugf(calldepth int, format string, v ...interface{})
Info(calldepth int, v ...interface{})
Infof(calldepth int, format string, v ...interface{})
Warn(calldepth int, v ...interface{})
Warnf(calldepth int, format string, v ...interface{})
Error(calldepth int, v ...interface{})
Errorf(calldepth int, format string, v ...interface{})
Panic(calldepth int, v ...interface{})
Panicf(calldepth int, format string, v ...interface{})
Fatal(calldepth int, v ...interface{})
Fatalf(calldepth int, format string, v ...interface{})
}
Logger in tao
var TaoLogger Logger
TaoLogger in global default to provide based log print
type Parameter ¶
type Parameter interface {
Get(key string) (val interface{})
Set(key string, val interface{})
Clone() Parameter
Delete(key string)
String() string
}
Parameter describe function input or output
type Pipeline ¶
Pipeline to run tasks in order pipeline is also a task
func NewPipeline ¶
func NewPipeline(name string, options ...PipelineOption) Pipeline
NewPipeline constructor of Pipeline
type PipelineOption ¶
type PipelineOption func(p *pipeline)
PipelineOption optional function of pipeline
func SetPostStartTask ¶
func SetPostStartTask(t *pipeTask) PipelineOption
SetPostStartTask of pipeline
type TaoConfig ¶
type TaoConfig struct {
LogLevel `json:"log_level"`
}
TaoConfig implements Config
type Task ¶
type Task interface {
Name() string
Run(ctx context.Context, param Parameter) error
Result() Parameter
Error() string
Close() error
}
Task single Task
Click to show internal directories.
Click to hide internal directories.