interceptor

package
v1.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2023 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetricCronPerformance = "cron_performance"
)

Variables

This section is empty.

Functions

func DefaultKV added in v1.5.0

func DefaultKV(method string, err error) map[string]string

DefaultKV returns a standardized service tracking.

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

func RequestID(
	ctx context.Context,
	job *cronx.Job,
	handler cronx.Handler,
) error

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
}

type SlackClientItf added in v1.5.0

type SlackClientItf interface {
	Send(ctx context.Context, msg string, mention bool)
}

type TelemetryClientItf added in v1.5.0

type TelemetryClientItf interface {
	Histogram(metricName string, value float64, tags map[string]string)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL