github.com/TBD54566975/ftl@v0.219.0/internal/unstoppable/unstoppable.go (about) 1 package unstoppable 2 3 import ( 4 "context" 5 "time" 6 ) 7 8 // Context returns a sub-context that is not cancellable. 9 func Context(ctx context.Context) context.Context { 10 return unstoppableContext{parent: ctx, ch: make(chan struct{})} 11 } 12 13 //nolint:containedctx 14 type unstoppableContext struct { 15 parent context.Context 16 ch chan struct{} 17 } 18 19 func (u unstoppableContext) Deadline() (deadline time.Time, ok bool) { return time.Time{}, false } 20 func (u unstoppableContext) Done() <-chan struct{} { return u.ch } 21 func (u unstoppableContext) Err() error { return nil } 22 func (u unstoppableContext) Value(key any) any { return u.parent.Value(key) }