# README
otasyncgo
OpenTracing plugin for spawns new goroutine.
Usage
package main
import (
"context"
"fmt"
"github.com/yuewokeji/opentracing-go-plugins/module/otasyncgo"
"time"
)
func main() {
fn := func(ctx context.Context) error {
fmt.Println("from another goroutine")
return nil
}
// create a goroutine and call the function fn
otasyncgo.GoWithRecoverOnce(context.Background(), "another-goroutine", fn)
time.Sleep(time.Second * 3)
}
# Functions
创建一个goroutine,执行fn() 如果发生panic,在retry次数内,会sleep一个interval周期后,重新开启新的goroutine
traceCtx:与链路追踪相关的上下文,这个上下文仅用来链接到caller,随后会被销毁 如果你需要使用context的特性,请使用WithContext() 当然,你可以传递traceCtx,即WithContext(traceCtx) serviceName:服务名,对应链路追踪的span name.
创建一个goroutine,执行fn(),只执行一次.
创建一个goroutine,执行fn() 如果发生panic,会sleep一个interval周期后,重新开启新的goroutine,没有次数限制 任何一次创建goroutine,链路追踪都会生成一个新的traceID.
指定一个上下文.
设置时间间隔.
设置重试次数.
No description provided by the author