integrations

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

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

func AsynqPanicHandler(ctx context.Context, task AsynqTask)

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

func AsynqRecoverHandler(ctx context.Context, task AsynqTask) error

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

func EchoPanicHandler(r *http.Request, recovered interface{})

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

func GinPanicHandler(r *http.Request, recovered interface{})

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

func HTTPMiddleware(next http.Handler) http.Handler

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

func MachineryRecoverHandler(taskName string) error

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

func RiverPanicHandler(ctx context.Context, job interface{})

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

func RiverRecoverHandler(ctx context.Context, job interface{}) error

RiverRecoverHandler is similar to RiverPanicHandler but doesn't re-panic. Use this when you want to gracefully handle panics.

Types

type AsynqTask

type AsynqTask interface {
	Type() string
	Payload() []byte
}

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

type MachineryTask interface {
	GetName() string
	GetUUID() string
}

MachineryTask represents the interface for a Machinery task. This allows the integration to work without importing machinery directly.

type RiverJob

type RiverJob interface {
	Kind() string
}

RiverJob represents the interface for a River job. This allows the integration to work without importing river directly.

type RiverJobRow

type RiverJobRow struct {
	ID          int64
	Queue       string
	Kind        string
	Args        interface{}
	Attempt     int
	MaxAttempts int
	Priority    int
	State       string
}

RiverJobRow represents job metadata from River.

Jump to

Keyboard shortcuts

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