mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
fix(region): app replace backgroud ctx
This commit is contained in:
@@ -40,6 +40,7 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/i18n"
|
||||
"yunion.io/x/onecloud/pkg/proxy"
|
||||
"yunion.io/x/onecloud/pkg/util/ctx"
|
||||
"yunion.io/x/onecloud/pkg/util/httputils"
|
||||
)
|
||||
|
||||
@@ -82,7 +83,7 @@ var quitHandlerRegisted bool
|
||||
|
||||
func NewApplication(name string, connMax int, db bool) *Application {
|
||||
app := Application{name: name,
|
||||
context: context.Background(),
|
||||
context: ctx.CtxWithTime(),
|
||||
connMax: connMax,
|
||||
session: NewWorkerManager("HttpRequestWorkerManager", connMax, DEFAULT_BACKLOG, db),
|
||||
readSession: NewWorkerManager("HttpGetRequestWorkerManager", connMax, DEFAULT_BACKLOG, db),
|
||||
|
||||
@@ -35,6 +35,7 @@ var (
|
||||
)
|
||||
|
||||
func StartTenantCacheSync(ctx context.Context, intvalSeconds int) {
|
||||
|
||||
go runTenantCacheSync(ctx, intvalSeconds)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package ctx
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
CTX_TIME_KEY = "time"
|
||||
)
|
||||
|
||||
func CtxWithTime() context.Context {
|
||||
return context.WithValue(context.Background(), CTX_TIME_KEY, time.Now())
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
package ctx // import "yunion.io/x/onecloud/pkg/util/ctx"
|
||||
Reference in New Issue
Block a user