recovery

package
v0.0.0-...-be573ad Latest Latest
Warning

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

Go to latest
Published: May 11, 2024 License: MIT Imports: 8 Imported by: 1

Documentation

Overview

Package recovery 提供适配 tRPC 的捕获异常工具

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CatchPanic

func CatchPanic(opts ...Option)

CatchPanic 捕获异常

Types

type Option

type Option func(opt *option)

Option 表示额外参数

func WithCallback

func WithCallback(f PanicCallback) Option

WithCallback 出现 panic 时回调

func WithContext

func WithContext(ctx context.Context) Option

WithContext context 参数

func WithErrorLog

func WithErrorLog() Option

WithErrorLog 在 panic 时打印详细的错误日志

func WithMetrics

func WithMetrics(key string) Option

WithMetrics 当 panic 时调用 metrics.Counter(key).Incr()

type PanicCallback

type PanicCallback func(ctx context.Context, info any, stack []caller.Caller)

PanicCallback 发生 panic 时的回调函数

Jump to

Keyboard shortcuts

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