Documentation
¶
Index ¶
- func AsynqErrorHandler(ctx context.Context, task AsynqTask, err error, opts ...checkend.NotifyOption)
- func AsynqErrorHandlerWithInfo(ctx context.Context, info *AsynqTaskInfo, err error, ...)
- func AsynqMiddleware() func(next interface{}) interface{}
- func AsynqPanicHandler(ctx context.Context, task AsynqTask)
- func AsynqRecoverHandler(ctx context.Context, task AsynqTask) error
- func EchoErrorHandler(r *http.Request, err error, opts ...checkend.NotifyOption)
- func EchoMiddleware() interface{}
- func EchoPanicHandler(r *http.Request, recovered interface{})
- func EchoRecoveryMiddleware() interface{}
- func GinErrorHandler(r *http.Request, err error, opts ...checkend.NotifyOption)
- func GinMiddleware() interface{}
- func GinPanicHandler(r *http.Request, recovered interface{})
- func GinRecovery() interface{}
- func HTTPMiddleware(next http.Handler) http.Handler
- func HTTPMiddlewareFunc(next http.HandlerFunc) http.HandlerFunc
- func MachineryErrorHandler(ctx context.Context, taskName string, err error, opts ...checkend.NotifyOption)
- func MachineryErrorHandlerWithSignature(ctx context.Context, sig *MachinerySignature, err error, ...)
- func MachineryOnTaskFailure() func(signature interface{}, err error)
- func MachineryOnTaskSuccessWithError() func(signature interface{}, results []interface{})
- func MachineryPanicHandler(taskName string)
- func MachineryRecoverHandler(taskName string) error
- func RiverErrorHandler(ctx context.Context, job interface{}, err error, opts ...checkend.NotifyOption)
- func RiverErrorHandlerWithRow(ctx context.Context, row *RiverJobRow, err error, ...)
- func RiverErrorMiddleware() interface{}
- func RiverPanicHandler(ctx context.Context, job interface{})
- func RiverRecoverHandler(ctx context.Context, job interface{}) error
- type AsynqTask
- type AsynqTaskInfo
- type GinContextExtractor
- type MachinerySignature
- type MachineryTask
- type RiverJob
- type RiverJobRow
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsynqErrorHandler ¶
func AsynqErrorHandler(ctx context.Context, task AsynqTask, err error, opts ...checkend.NotifyOption)
AsynqErrorHandler reports task errors to Checkend. Call this in your task handler's error handling logic.
Usage:
func handleTask(ctx context.Context, task *asynq.Task) error {
err := doWork()
if err != nil {
integrations.AsynqErrorHandler(ctx, task, err)
return err
}
return nil
}
func AsynqErrorHandlerWithInfo ¶
func AsynqErrorHandlerWithInfo(ctx context.Context, info *AsynqTaskInfo, err error, opts ...checkend.NotifyOption)
AsynqErrorHandlerWithInfo reports task errors with additional task info.
func AsynqMiddleware ¶
func AsynqMiddleware() func(next interface{}) interface{}
AsynqMiddleware creates middleware that wraps Asynq task handlers with error reporting and panic recovery.
Usage with Asynq:
mux := asynq.NewServeMux()
mux.Use(integrations.AsynqMiddleware())
mux.HandleFunc("email:send", handleEmailTask)
func AsynqPanicHandler ¶
AsynqPanicHandler handles panics in Asynq task handlers. Use this with defer in your task handlers.
Usage:
func handleTask(ctx context.Context, task *asynq.Task) error {
defer integrations.AsynqPanicHandler(ctx, task)
// ... task logic
}
func AsynqRecoverHandler ¶
AsynqRecoverHandler is similar to AsynqPanicHandler but doesn't re-panic. Use this when you want to gracefully handle panics without triggering retries.
func EchoErrorHandler ¶
func EchoErrorHandler(r *http.Request, err error, opts ...checkend.NotifyOption)
EchoErrorHandler is a helper for handling errors in Echo handlers.
Usage:
func MyHandler(c echo.Context) error {
if err := doSomething(); err != nil {
integrations.EchoErrorHandler(c.Request(), err)
return c.JSON(500, map[string]string{"error": "internal error"})
}
return nil
}
func EchoMiddleware ¶
func EchoMiddleware() interface{}
EchoMiddleware returns an Echo middleware for Checkend error reporting. This middleware is compatible with the labstack/echo framework.
Usage:
import "github.com/labstack/echo/v4" import "github.com/Checkend/checkend-go/integrations" e := echo.New() e.Use(integrations.EchoMiddleware())
func EchoPanicHandler ¶
EchoPanicHandler handles panics and reports them to Checkend.
func EchoRecoveryMiddleware ¶
func EchoRecoveryMiddleware() interface{}
EchoRecoveryMiddleware returns a recovery middleware that reports panics.
func GinErrorHandler ¶
func GinErrorHandler(r *http.Request, err error, opts ...checkend.NotifyOption)
GinErrorHandler is a helper for handling errors in Gin handlers. Use this in your handlers to report errors to Checkend.
Usage:
func MyHandler(c *gin.Context) {
if err := doSomething(); err != nil {
integrations.GinErrorHandler(c.Request, err)
c.JSON(500, gin.H{"error": "internal error"})
return
}
}
func GinMiddleware ¶
func GinMiddleware() interface{}
GinMiddleware returns a Gin middleware for Checkend error reporting. This middleware is compatible with the gin-gonic/gin framework.
Usage:
import "github.com/gin-gonic/gin" import "github.com/Checkend/checkend-go/integrations" r := gin.New() r.Use(integrations.GinMiddleware())
func GinPanicHandler ¶
GinPanicHandler handles panics and reports them to Checkend.
func GinRecovery ¶
func GinRecovery() interface{}
GinRecovery returns a recovery middleware that reports panics to Checkend. Use this instead of gin.Recovery() to capture panic errors.
Usage:
r := gin.New() r.Use(integrations.GinRecovery())
func HTTPMiddleware ¶
HTTPMiddleware wraps an http.Handler with Checkend error reporting.
func HTTPMiddlewareFunc ¶
func HTTPMiddlewareFunc(next http.HandlerFunc) http.HandlerFunc
HTTPMiddlewareFunc wraps an http.HandlerFunc with Checkend error reporting.
func MachineryErrorHandler ¶
func MachineryErrorHandler(ctx context.Context, taskName string, err error, opts ...checkend.NotifyOption)
MachineryErrorHandler reports task errors to Checkend. Call this in your task's error handling logic.
Usage with Machinery:
func sendEmailTask(email string) error {
err := sendEmail(email)
if err != nil {
integrations.MachineryErrorHandler(context.Background(), "send_email", err)
return err
}
return nil
}
func MachineryErrorHandlerWithSignature ¶
func MachineryErrorHandlerWithSignature(ctx context.Context, sig *MachinerySignature, err error, opts ...checkend.NotifyOption)
MachineryErrorHandlerWithSignature reports task errors with full signature metadata.
func MachineryOnTaskFailure ¶
func MachineryOnTaskFailure() func(signature interface{}, err error)
MachineryOnTaskFailure creates a callback for Machinery's OnTaskFailure hook. Use this when configuring Machinery server callbacks.
Usage:
server.SetErrorHandler(integrations.MachineryOnTaskFailure())
func MachineryOnTaskSuccessWithError ¶
func MachineryOnTaskSuccessWithError() func(signature interface{}, results []interface{})
MachineryOnTaskSuccessWithError creates a callback that reports errors even when the task "succeeds" but returns an error value.
func MachineryPanicHandler ¶
func MachineryPanicHandler(taskName string)
MachineryPanicHandler handles panics in Machinery tasks. Use this with defer in your task functions.
Usage:
func myTask(args ...interface{}) error {
defer integrations.MachineryPanicHandler("my_task")
// ... task logic
}
func MachineryRecoverHandler ¶
MachineryRecoverHandler is similar to MachineryPanicHandler but doesn't re-panic.
func RiverErrorHandler ¶
func RiverErrorHandler(ctx context.Context, job interface{}, err error, opts ...checkend.NotifyOption)
RiverErrorHandler reports job errors to Checkend. Call this in your job worker's error handling logic.
Usage with River:
type EmailWorker struct {
river.WorkerDefaults[EmailArgs]
}
func (w *EmailWorker) Work(ctx context.Context, job *river.Job[EmailArgs]) error {
err := sendEmail(job.Args)
if err != nil {
integrations.RiverErrorHandler(ctx, job, err)
return err
}
return nil
}
func RiverErrorHandlerWithRow ¶
func RiverErrorHandlerWithRow(ctx context.Context, row *RiverJobRow, err error, opts ...checkend.NotifyOption)
RiverErrorHandlerWithRow reports job errors with job row metadata.
func RiverErrorMiddleware ¶
func RiverErrorMiddleware() interface{}
RiverErrorMiddleware creates an error handler middleware for River. This can be used with River's error handler configuration.
Usage:
client, _ := river.NewClient(riverpgxv5.New(pool), &river.Config{
ErrorHandler: integrations.RiverErrorMiddleware(),
})
func RiverPanicHandler ¶
RiverPanicHandler handles panics in River job workers. Use this with defer in your job workers.
Usage:
func (w *MyWorker) Work(ctx context.Context, job *river.Job[MyArgs]) error {
defer integrations.RiverPanicHandler(ctx, job)
// ... job logic
}
func RiverRecoverHandler ¶
RiverRecoverHandler is similar to RiverPanicHandler but doesn't re-panic. Use this when you want to gracefully handle panics.
Types ¶
type AsynqTask ¶
AsynqTask represents the interface for an Asynq task. This allows the integration to work without importing asynq directly.
type AsynqTaskInfo ¶
type AsynqTaskInfo struct {
ID string
Queue string
Type string
Payload []byte
Retried int
MaxRetry int
}
AsynqTaskInfo represents task metadata from Asynq.
type GinContextExtractor ¶
type GinContextExtractor struct{}
GinContextExtractor is a helper type for extracting context from Gin. Use the Extract method in your handlers to get Checkend context.
func NewGinContextExtractor ¶
func NewGinContextExtractor() *GinContextExtractor
NewGinContextExtractor creates a new GinContextExtractor.
func (*GinContextExtractor) ExtractFromRequest ¶
func (e *GinContextExtractor) ExtractFromRequest(r *http.Request) map[string]interface{}
ExtractFromRequest extracts Checkend context from an http.Request. This can be used with Gin's c.Request field.
type MachinerySignature ¶
type MachinerySignature struct {
UUID string
Name string
RoutingKey string
Args []interface{}
RetryCount int
RetryTimeout int
}
MachinerySignature represents task metadata from Machinery.
type MachineryTask ¶
MachineryTask represents the interface for a Machinery task. This allows the integration to work without importing machinery directly.