mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 23:05:15 +00:00
bbgo: add NewContextWithIsolation function
This commit is contained in:
parent
f7e76c0518
commit
198683d141
|
@ -6,11 +6,7 @@ import (
|
||||||
|
|
||||||
const IsolationContextKey = "bbgo"
|
const IsolationContextKey = "bbgo"
|
||||||
|
|
||||||
var defaultIsolation *Isolation = nil
|
var defaultIsolation = NewIsolation()
|
||||||
|
|
||||||
func init() {
|
|
||||||
defaultIsolation = NewIsolation()
|
|
||||||
}
|
|
||||||
|
|
||||||
type Isolation struct {
|
type Isolation struct {
|
||||||
gracefulShutdown GracefulShutdown
|
gracefulShutdown GracefulShutdown
|
||||||
|
@ -28,3 +24,7 @@ func NewIsolationFromContext(ctx context.Context) *Isolation {
|
||||||
|
|
||||||
return defaultIsolation
|
return defaultIsolation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewContextWithIsolation(parent context.Context, isolation *Isolation) context.Context {
|
||||||
|
return context.WithValue(parent, IsolationContextKey, isolation)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user