Skip to content

Commit a0aa801

Browse files
committed
add closed cb check
1 parent f136b75 commit a0aa801

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

capture.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,14 @@ func (c *Capture[P, K]) Run(ctx context.Context, nc *nats.Conn) error {
7979
err error
8080
)
8181

82-
// TODO(jonathan): check if the incoming connection already has a ClosedHandler
82+
oldClosedCB := nc.Opts.ClosedCB
8383

8484
wg.Add(1)
85-
c.nc.SetClosedHandler(func(*nats.Conn) {
85+
c.nc.SetClosedHandler(func(_nc *nats.Conn) {
86+
if oldClosedCB != nil {
87+
oldClosedCB(_nc)
88+
}
89+
8690
log.Info("nats.ClosedHandler")
8791
wg.Done()
8892
})

0 commit comments

Comments
 (0)