Compare commits
2 Commits
7509b6c8c6
...
f67d78b5e6
Author | SHA1 | Date | |
---|---|---|---|
|
f67d78b5e6 | ||
|
f217055e4a |
@ -2,6 +2,8 @@ package tool
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitea.loveuer.com/yizhisec/packages/opt"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -21,7 +23,7 @@ func Timeout(seconds ...int) (ctx context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
func TimeoutCtx(ctx context.Context, seconds ...int) context.Context {
|
||||
func CtxTimeout(ctx context.Context, seconds ...int) context.Context {
|
||||
var (
|
||||
duration time.Duration
|
||||
)
|
||||
@ -36,3 +38,7 @@ func TimeoutCtx(ctx context.Context, seconds ...int) context.Context {
|
||||
|
||||
return nctx
|
||||
}
|
||||
|
||||
func CtxTrace(ctx context.Context, key string) context.Context {
|
||||
return context.WithValue(ctx, opt.TraceKey, fmt.Sprintf("%36s", key))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user