Compare commits
2 Commits
7509b6c8c6
...
f67d78b5e6
Author | SHA1 | Date | |
---|---|---|---|
|
f67d78b5e6 | ||
|
f217055e4a |
@ -2,6 +2,8 @@ package tool
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"gitea.loveuer.com/yizhisec/packages/opt"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -21,7 +23,7 @@ func Timeout(seconds ...int) (ctx context.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func TimeoutCtx(ctx context.Context, seconds ...int) context.Context {
|
func CtxTimeout(ctx context.Context, seconds ...int) context.Context {
|
||||||
var (
|
var (
|
||||||
duration time.Duration
|
duration time.Duration
|
||||||
)
|
)
|
||||||
@ -36,3 +38,7 @@ func TimeoutCtx(ctx context.Context, seconds ...int) context.Context {
|
|||||||
|
|
||||||
return nctx
|
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