Preserve independent background sessions through owner shutdown and idle cleanup
This commit is contained in:
@@ -55,8 +55,9 @@ type bridge struct {
|
||||
detached time.Time
|
||||
}
|
||||
|
||||
// Options describes one private, database-scoped bridge. MaxDetached bounds its
|
||||
// lifetime without a Pipelines client, even with an unresolved approval.
|
||||
// Options describes one private, database-scoped bridge. Positive timeout
|
||||
// values opt into detached expiry; zero keeps the original upstream connection
|
||||
// and its live sessions/callbacks until explicitly stopped.
|
||||
type Options struct {
|
||||
Dir, Upstream string
|
||||
Idle, MaxDetached time.Duration
|
||||
@@ -221,7 +222,7 @@ func (h *bridge) expire(idle, maxDetached time.Duration) {
|
||||
return
|
||||
case <-ticker.C:
|
||||
h.mu.Lock()
|
||||
expired := h.active == nil && (time.Since(h.detached) >= maxDetached || (len(h.pending) == 0 && time.Since(h.detached) >= idle))
|
||||
expired := h.active == nil && ((maxDetached > 0 && time.Since(h.detached) >= maxDetached) || (idle > 0 && len(h.pending) == 0 && time.Since(h.detached) >= idle))
|
||||
h.mu.Unlock()
|
||||
if expired {
|
||||
h.cancel()
|
||||
|
||||
Reference in New Issue
Block a user