create a deferral to automatically close sessions after creating them during boundary connect (#6054)

This commit is contained in:
dani authored and GitHub committed 2025-09-16 13:55:34 -04:00
1 parent 5f6cb00108
commit 5ebf11caeb
2 files changed
+45 -16

No files matched your search

+10 -2
View File
@@ -350,12 +350,20 @@ func (p *ClientProxy) Start(opt ...Option) (retErr error) {
return nil
}
ctx, cancel := context.WithTimeout(context.Background(), opts.withSessionTeardownTimeout)
return p.CloseSession(opts.withSessionTeardownTimeout)
}
// CloseSession attempts to close the currently proxied session by sending a
// request to do so to the worker proxying the connection
func (p *ClientProxy) CloseSession(sessionTeardownTimeout time.Duration) error {
if sessionTeardownTimeout == 0 {
sessionTeardownTimeout = sessionCancelTimeout
}
ctx, cancel := context.WithTimeout(context.Background(), sessionTeardownTimeout)
defer cancel()
if err := p.sendSessionTeardown(ctx); err != nil {
return fmt.Errorf("error sending session teardown request to worker: %w", err)
}
return nil
}