gofunc

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 6 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// EmptyInfo is empty Info which is convenient to reuse
	EmptyInfo = &Info{}
)

Functions

func RecoverGoFuncWithInfo added in v0.1.0

func RecoverGoFuncWithInfo(ctx context.Context, task func(), info *Info)

RecoverGoFuncWithInfo is the go func with recover panic and service info. It is used for panic defence and output key info for troubleshooting.

func SetPanicHandler added in v0.1.0

func SetPanicHandler(hdlr func(info *Info, panicErr interface{}, panicStack string))

SetPanicHandler is used to do something when panic happen, for example do metric report.

Types

type GoTask

type GoTask func(context.Context, func())

GoTask is used to spawn a new task.

var GoFunc GoTask

GoFunc is the default func used globally.

type Info added in v0.1.0

type Info struct {
	RemoteService string
	RemoteAddr    string
}

Info is used to pass key info to go func, which is convenient for troubleshooting

func NewBasicInfo added in v0.1.0

func NewBasicInfo(remoteService, remoteAddr string) *Info

NewBasicInfo is to new Info with remoteService and remoteAddr.

Jump to

Keyboard shortcuts

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