mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +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)
|
todo := context.WithValue(context.TODO(), IsolationContextKey, isolatedContext)
|
||||||
|
|
||||||
timeoutCtx, cancel := context.WithTimeout(todo, 30*time.Second)
|
timeoutCtx, cancel := context.WithTimeout(todo, 30*time.Second)
|
||||||
defaultIsolationContext.gracefulShutdown.Shutdown(timeoutCtx)
|
defaultIsolation.gracefulShutdown.Shutdown(timeoutCtx)
|
||||||
cancel()
|
cancel()
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,25 +6,25 @@ import (
|
||||||
|
|
||||||
const IsolationContextKey = "bbgo"
|
const IsolationContextKey = "bbgo"
|
||||||
|
|
||||||
var defaultIsolationContext *IsolationContext = nil
|
var defaultIsolation *Isolation = nil
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
defaultIsolationContext = NewIsolation()
|
defaultIsolation = NewIsolation()
|
||||||
}
|
}
|
||||||
|
|
||||||
type IsolationContext struct {
|
type Isolation struct {
|
||||||
gracefulShutdown GracefulShutdown
|
gracefulShutdown GracefulShutdown
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewIsolation() *IsolationContext {
|
func NewIsolation() *Isolation {
|
||||||
return &IsolationContext{}
|
return &Isolation{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewIsolationFromContext(ctx context.Context) *IsolationContext {
|
func NewIsolationFromContext(ctx context.Context) *Isolation {
|
||||||
isolatedContext, ok := ctx.Value(IsolationContextKey).(*IsolationContext)
|
isolatedContext, ok := ctx.Value(IsolationContextKey).(*Isolation)
|
||||||
if ok {
|
if ok {
|
||||||
return isolatedContext
|
return isolatedContext
|
||||||
}
|
}
|
||||||
|
|
||||||
return defaultIsolationContext
|
return defaultIsolation
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user