Documentation ¶
Index ¶
- Constants
- func DefaultKV(method string, err error) map[string]string
- func DefaultWorkerPool() cronx.Interceptor
- func DistributedLock(serviceName string, mode string, dl DistributedLockItf, sc SlackClientItf) cronx.Interceptor
- func Logger() cronx.Interceptor
- func NotifySlack(serviceName string, mode string, sc SlackClientItf) cronx.Interceptor
- func Recover() cronx.Interceptor
- func RecoverWithAlert(serviceName string, mode string, sc SlackClientItf) cronx.Interceptor
- func RequestID(ctx context.Context, job *cronx.Job, handler cronx.Handler) error
- func Telemetry(metric TelemetryClientItf) cronx.Interceptor
- func WorkerPool(size int) cronx.Interceptor
- type DistributedLockItf
- type SlackClientItf
- type TelemetryClientItf
Constants ¶
const (
MetricCronPerformance = "cron_performance"
)
Variables ¶
This section is empty.
Functions ¶
func DefaultWorkerPool ¶
func DefaultWorkerPool() cronx.Interceptor
DefaultWorkerPool returns a WorkerPool middleware with default configuration.
func DistributedLock ¶ added in v1.5.0
func DistributedLock( serviceName string, mode string, dl DistributedLockItf, sc SlackClientItf, ) cronx.Interceptor
DistributedLock is a middleware that prevents a process executed at the same time across servers.
func Logger ¶
func Logger() cronx.Interceptor
Logger is a middleware that logs the current job start and finish.
func NotifySlack ¶ added in v1.5.0
func NotifySlack( serviceName string, mode string, sc SlackClientItf, ) cronx.Interceptor
NotifySlack is a middleware that send alert to slack on error.
func Recover ¶
func Recover() cronx.Interceptor
Recover is a middleware that recovers server from panic. Recover also dumps stack trace on panic occurrence.
func RecoverWithAlert ¶ added in v1.5.0
func RecoverWithAlert( serviceName string, mode string, sc SlackClientItf, ) cronx.Interceptor
RecoverWithAlert is a middleware that recovers server from panic. On panic occurrence, we will dump the stack trace and send alert to Slack.
func RequestID ¶
RequestID is a middleware that inject request id to the context if it doesn't exist.
func Telemetry ¶ added in v1.5.0
func Telemetry(metric TelemetryClientItf) cronx.Interceptor
Telemetry is a middleware that push the latency of a process.
func WorkerPool ¶
func WorkerPool(size int) cronx.Interceptor
WorkerPool is a middleware that limit total cron that can run a time. Program is running on a server with finite amount of resources such as CPU and RAM. By limiting the total number of jobs that can be run the same time, we protect the server from overloading.
Types ¶
type DistributedLockItf ¶ added in v1.5.0
type DistributedLockItf interface {
Mutex(name string) *redsync.Mutex
}