feat(global):全局增加一个用于生成带有超时控制的上下文生成器。
This commit is contained in:
parent
ae6e6490b2
commit
b262042244
10
global/context.go
Normal file
10
global/context.go
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package global
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TimeoutContext(timeout time.Duration) (context.Context, context.CancelFunc) {
|
||||||
|
return context.WithTimeout(context.Background(), timeout)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user