Documentation
¶
Index ¶
- func Wait()
- type Context
- type ContextImpl
- func (ctx *ContextImpl) AddMetadata(metadata Metadata) Context
- func (ctx *ContextImpl) AddSingleMetadata(key string, args interface{}) Context
- func (ctx *ContextImpl) Cancel()
- func (ctx *ContextImpl) Context() context.Context
- func (ctx *ContextImpl) Copy(baseCtxIn ...context.Context) Context
- func (ctx *ContextImpl) Done() <-chan struct{}
- func (ctx *ContextImpl) Err() error
- func (ctx *ContextImpl) GetLatency() float64
- func (ctx *ContextImpl) ID() ID
- func (ctx *ContextImpl) LogDebug(msg string, fields ...LogFields)
- func (ctx *ContextImpl) LogError(err error, fields ...LogFields)
- func (ctx *ContextImpl) LogErrorMsg(msg string, fields ...LogFields)
- func (ctx *ContextImpl) LogFatal(msg string, fields ...LogFields)
- func (ctx *ContextImpl) LogInfo(msg string, fields ...LogFields)
- func (ctx *ContextImpl) LogPanic(msg string, fields ...LogFields)
- func (ctx *ContextImpl) LogWarn(msg string, fields ...LogFields)
- func (ctx *ContextImpl) Name() string
- func (ctx *ContextImpl) NewHistogram(key string) *Histogram
- func (ctx *ContextImpl) NewIndicator(key string) *Indicator
- func (ctx *ContextImpl) Retry(retries int8) *retry
- func (ctx *ContextImpl) RoutineID() ID
- type Event
- type EventMetric
- type Histogram
- type ID
- type ILogger
- type IOutis
- type Indicator
- type LogFields
- type LogLevel
- type LogOptions
- type Metadata
- type Option
- func WithDesc(desc string) Option
- func WithExecuteFirstTimeBeforeInterval() Option
- func WithHours(start, end uint) Option
- func WithID(id ID) Option
- func WithInterval(duration time.Duration) Option
- func WithMinutes(start, end uint) Option
- func WithName(name string) Option
- func WithNotUseLoop() Option
- func WithScript(fn func(Context) error) Option
- type RoutineMetric
- type Watch
- type WatcherMetric
- type WatcherOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Context ¶
type Context interface {
Context() context.Context
Cancel()
Done() <-chan struct{}
Err() error
Copy(baseCtxIn ...context.Context) Context
GetLatency() float64
LogInfo(msg string, fields ...LogFields)
LogError(err error, fields ...LogFields)
LogErrorMsg(msg string, fields ...LogFields)
LogFatal(msg string, fields ...LogFields)
LogPanic(msg string, fields ...LogFields)
LogDebug(msg string, fields ...LogFields)
LogWarn(msg string, fields ...LogFields)
AddSingleMetadata(key string, args interface{}) Context
AddMetadata(metadata Metadata) Context
Name() string
RoutineID() ID
ID() ID
}
Context defines the data structure of the routine context.
type ContextImpl ¶ added in v1.4.0
type ContextImpl struct {
Desc string
Interval time.Duration
Path string
RunAt time.Time
Watcher Watch
// contains filtered or unexported fields
}
ContextImpl implements context interface
func (*ContextImpl) AddMetadata ¶ added in v1.4.0
func (ctx *ContextImpl) AddMetadata(metadata Metadata) Context
AddMetadata método adiciona metadata no contexto.
func (*ContextImpl) AddSingleMetadata ¶ added in v1.4.0
func (ctx *ContextImpl) AddSingleMetadata(key string, args interface{}) Context
AddSingleMetadata método adiciona 1 metadata no contexto.
func (*ContextImpl) Cancel ¶ added in v1.4.0
func (ctx *ContextImpl) Cancel()
Cancel cancela o contexto.
func (*ContextImpl) Context ¶ added in v1.4.0
func (ctx *ContextImpl) Context() context.Context
Context retorna o context.Context.
func (*ContextImpl) Copy ¶ added in v1.4.0
func (ctx *ContextImpl) Copy(baseCtxIn ...context.Context) Context
Copy cria um cópia do contexto atual.
func (*ContextImpl) Done ¶ added in v1.4.0
func (ctx *ContextImpl) Done() <-chan struct{}
Done retorna um canal que espera o canal ser finalizado.
func (*ContextImpl) Err ¶ added in v1.4.0
func (ctx *ContextImpl) Err() error
Err retorna o erro no contexto.
func (*ContextImpl) GetLatency ¶ added in v1.4.0
func (ctx *ContextImpl) GetLatency() float64
GetLatency get script execution latency (in seconds).
func (*ContextImpl) ID ¶ added in v1.4.0
func (ctx *ContextImpl) ID() ID
ID returns the execution ID of the routine
func (*ContextImpl) LogDebug ¶ added in v1.4.0
func (ctx *ContextImpl) LogDebug(msg string, fields ...LogFields)
LogDebug executa a função Debug do log do contexto.
func (*ContextImpl) LogError ¶ added in v1.4.0
func (ctx *ContextImpl) LogError(err error, fields ...LogFields)
LogError executa a função Error do log do contexto.
func (*ContextImpl) LogErrorMsg ¶ added in v1.4.0
func (ctx *ContextImpl) LogErrorMsg(msg string, fields ...LogFields)
LogErrorMsg executa a função ErrorMsg do log do contexto com uma mensagem de erro.
func (*ContextImpl) LogFatal ¶ added in v1.4.0
func (ctx *ContextImpl) LogFatal(msg string, fields ...LogFields)
LogFatal executa a função Fatal do log do contexto.
func (*ContextImpl) LogInfo ¶ added in v1.4.0
func (ctx *ContextImpl) LogInfo(msg string, fields ...LogFields)
LogInfo executa a função Info do log do contexto.
func (*ContextImpl) LogPanic ¶ added in v1.4.0
func (ctx *ContextImpl) LogPanic(msg string, fields ...LogFields)
LogPanic executa a função Panic do log do contexto.
func (*ContextImpl) LogWarn ¶ added in v1.4.0
func (ctx *ContextImpl) LogWarn(msg string, fields ...LogFields)
LogWarn executa a função Warn do log do contexto.
func (*ContextImpl) Name ¶ added in v1.4.0
func (ctx *ContextImpl) Name() string
Name returns the name of the routine
func (*ContextImpl) NewHistogram ¶ added in v1.4.0
func (ctx *ContextImpl) NewHistogram(key string) *Histogram
NewHistogram creates a new histogram.
func (*ContextImpl) NewIndicator ¶ added in v1.4.0
func (ctx *ContextImpl) NewIndicator(key string) *Indicator
NewIndicator creates a new indicator.
func (*ContextImpl) Retry ¶ added in v1.4.0
func (ctx *ContextImpl) Retry(retries int8) *retry
Go returns the settings for using the Attempt method
func (*ContextImpl) RoutineID ¶ added in v1.4.0
func (ctx *ContextImpl) RoutineID() ID
RoutineID returns the ID of the routine
type EventMetric ¶
type EventMetric struct {
ID string
Latency time.Duration
StartedAt time.Time
FinishedAt time.Time
Watcher WatcherMetric
Routine RoutineMetric
Metadata Metadata
Indicators []*Indicator
Histograms []*Histogram
}
EventMetric defines the type of metric sent in the event
type Histogram ¶ added in v1.3.4
type Histogram struct {
// contains filtered or unexported fields
}
type ILogger ¶
type ILogger interface {
Level() LogLevel
Info(msg string, fields ...LogFields)
Error(erro error, fields ...LogFields)
ErrorMsg(errorMsg string, fields ...LogFields)
Fatal(msg string, fields ...LogFields)
Panic(msg string, fields ...LogFields)
Debug(msg string, fields ...LogFields)
Warn(msg string, fields ...LogFields)
AddFields(fields ...LogFields) ILogger
AddField(key string, value interface{}) ILogger
}
ILogger methods for logging messages.
type IOutis ¶
type IOutis interface {
Go(fn func() error)
Wait() error
Init(ctx Context) error
Before(ctx Context) error
After(ctx Context) error
Event(ctx Context, event Event)
}
IOutis is the main interface for implementing the outis lib.
type Indicator ¶ added in v1.3.4
type Indicator struct {
// contains filtered or unexported fields
}
func (*Indicator) GetCreatedAt ¶ added in v1.3.4
GetCreatedAt get the creation date of an indicator.
type LogFields ¶ added in v1.3.4
type LogFields map[string]interface{}
LogFields representa os campos do log
type LogLevel ¶ added in v1.3.4
type LogLevel string
LogLevel representa o level do log
const ( // DebugLevel representa o nível de debug do Log DebugLevel LogLevel = "DebugLevel" // InfoLevel representa o nível de info do Log InfoLevel LogLevel = "InfoLevel" // WarnLevel representa o nível de warn do Log WarnLevel LogLevel = "WarnLevel" // ErrorLevel representa o nível de error do Log ErrorLevel LogLevel = "ErrorLevel" // DPanicLevel representa o nível de dpanic do Log DPanicLevel LogLevel = "DPanicLevel" // PanicLevel representa o nível de panic do Log PanicLevel LogLevel = "PanicLevel" // FatalLevel representa o nível de fatal do Log FatalLevel LogLevel = "FatalLevel" )
type LogOptions ¶ added in v1.3.4
LogOptions representa as opções de configuração do log
type Metadata ¶
type Metadata map[string]interface{}
Metadata defines type of metadata used in metrics
type Option ¶
type Option func(*ContextImpl)
Option defines the option type of a routine
func WithExecuteFirstTimeBeforeInterval ¶ added in v1.3.9
func WithExecuteFirstTimeBeforeInterval() Option
WithExecuteFirstTimeNow define that the routine will execute first time when Watcher.Go is called
func WithInterval ¶
WithInterval defines the interval at which the script will be executed
func WithMinutes ¶
WithMinutes sets the start and end minutes of script execution
func WithNotUseLoop ¶
func WithNotUseLoop() Option
WithNotUseLoop define that the routine will not enter a loop
func WithScript ¶
WithScript defines the script function that will be executed
type RoutineMetric ¶
RoutineMetric defines the type of metric of a routine sent in the event
type Watch ¶
type Watch struct {
Id ID `json:"id"`
Name string `json:"name"`
RunAt time.Time `json:"run_at"`
// contains filtered or unexported fields
}
Watch defines the type of the watcher structure
func Watcher ¶
func Watcher(id, name string, opts ...WatcherOption) *Watch
Watcher initializes a new watcher
type WatcherMetric ¶
WatcherMetric defines the type of metric of a watcher sent in the event
type WatcherOption ¶
type WatcherOption func(*Watch)
WatcherOption defines the option type of a watcher
func Impl ¶
func Impl(outis IOutis) WatcherOption
Impl defines the implementation of the main interface
func Logger ¶
func Logger(logger ILogger) WatcherOption
Logger defines the implementation of the log interface