fix(region): app replace backgroud ctx

This commit is contained in:
zhaoxiangchun
2022-04-11 14:51:36 +08:00
parent a359b228c4
commit f82803f29d
4 changed files with 18 additions and 1 deletions
+2 -1
View File
@@ -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),
+1
View File
@@ -35,6 +35,7 @@ var (
)
func StartTenantCacheSync(ctx context.Context, intvalSeconds int) {
go runTenantCacheSync(ctx, intvalSeconds)
}
+14
View File
@@ -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())
}
+1
View File
@@ -0,0 +1 @@
package ctx // import "yunion.io/x/onecloud/pkg/util/ctx"