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 SetConfigBytesAll(data []byte, configType ConfigType) (err error)
- func Warn(v ...interface{})
- func Warnf(format string, v ...interface{})
- type Config
- type ConfigType
- type ErrorTao
- type ErrorUnWrapper
- type Log
- type LogLevel
- type LogType
- type Logger
- type Parameter
- type Pipeline
- type PipelineOption
- type TaoConfig
- type Task
- type TaskOption
- type TaskRun
- type TaskState
Constants ¶
const ( Unknown = "Unknown" ParamInvalid = "ParamInvalid" ContextCanceled = "ContextCanceled" DuplicateCall = "DuplicateCall" TaskRunTwice = "TaskRunTwice" TaskCloseTwice = "TaskCloseTwice" TaskClosed = "TaskClosed" TaskRunning = "TaskRunning" ConfigNotFound = "ConfigNotFound" )
* ErrorCode
const ConfigKey = "tao"
ConfigKey for this repo
Variables ¶
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
var TaoWriter io.Writer
TaoWriter for TaoLogger
Functions ¶
func GetConfigBytes ¶
GetConfigBytes by key of config
func NewPipeTask ¶
NewPipeTask constructor of pipeTask
func SetConfigBytesAll ¶ added in v0.0.2
func SetConfigBytesAll(data []byte, configType ConfigType) (err error)
SetConfigBytesAll from config file
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 ConfigType ¶ added in v0.0.2
type ConfigType uint8
Config Type
const ( Yaml ConfigType = iota Json )
type ErrorUnWrapper ¶
ErrorUnWrapper extension of error
func NewErrorUnWrapper ¶
func NewErrorUnWrapper(format string, e error) ErrorUnWrapper
NewErrorUnWrapper constructor of errorUnWrap
type Log ¶ added in v0.0.2
type Log struct {
Level LogLevel `json:"level"`
Type LogType `json:"type"`
Path string `json:"path"`
}
log config in tao
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 ¶
TaoConfig implements Config
var T *TaoConfig
T global config of tao
type Task ¶
type Task interface {
Name() string
Run(ctx context.Context, param Parameter) error
Result() Parameter
Error() string
Close() error
}
Task single Task