gofunc

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

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

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

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

type Info struct {
	RemoteService string
	RemoteAddr    string
}

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

func NewBasicInfo

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