mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 06:53:52 +00:00
bbgo: remove context suffix from the isolation struct
This commit is contained in:
parent
59287b5116
commit
315f7da8f4
|
@ -41,6 +41,6 @@ func Shutdown(ctx context.Context) {
|
|||
todo := context.WithValue(context.TODO(), IsolationContextKey, isolatedContext)
|
||||
|
||||
timeoutCtx, cancel := context.WithTimeout(todo, 30*time.Second)
|
||||
defaultIsolationContext.gracefulShutdown.Shutdown(timeoutCtx)
|
||||
defaultIsolation.gracefulShutdown.Shutdown(timeoutCtx)
|
||||
cancel()
|
||||
}
|
||||
|
|
|
@ -6,25 +6,25 @@ import (
|
|||
|
||||
const IsolationContextKey = "bbgo"
|
||||
|
||||
var defaultIsolationContext *IsolationContext = nil
|
||||
var defaultIsolation *Isolation = nil
|
||||
|
||||
func init() {
|
||||
defaultIsolationContext = NewIsolation()
|
||||
defaultIsolation = NewIsolation()
|
||||
}
|
||||
|
||||
type IsolationContext struct {
|
||||
type Isolation struct {
|
||||
gracefulShutdown GracefulShutdown
|
||||
}
|
||||
|
||||
func NewIsolation() *IsolationContext {
|
||||
return &IsolationContext{}
|
||||
func NewIsolation() *Isolation {
|
||||
return &Isolation{}
|
||||
}
|
||||
|
||||
func NewIsolationFromContext(ctx context.Context) *IsolationContext {
|
||||
isolatedContext, ok := ctx.Value(IsolationContextKey).(*IsolationContext)
|
||||
func NewIsolationFromContext(ctx context.Context) *Isolation {
|
||||
isolatedContext, ok := ctx.Value(IsolationContextKey).(*Isolation)
|
||||
if ok {
|
||||
return isolatedContext
|
||||
}
|
||||
|
||||
return defaultIsolationContext
|
||||
return defaultIsolation
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user