Skip to content

Commit

Permalink
Use getters to retrieve async handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrpio committed Dec 14, 2022
1 parent 972dcd2 commit d3ae7e5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions micro/service.go
Expand Up @@ -331,8 +331,8 @@ func (e *Endpoint) valid() error {
}

func (svc *service) setupAsyncCallbacks() {
svc.natsHandlers.closed = svc.conn.Opts.ClosedCB
if svc.conn.Opts.ClosedCB != nil {
svc.natsHandlers.closed = svc.conn.ClosedHandler()
if svc.natsHandlers.closed != nil {
svc.conn.SetClosedHandler(func(c *nats.Conn) {
svc.Stop()
svc.natsHandlers.closed(c)
Expand All @@ -343,8 +343,8 @@ func (svc *service) setupAsyncCallbacks() {
})
}

svc.natsHandlers.asyncErr = svc.conn.Opts.AsyncErrorCB
if svc.conn.Opts.AsyncErrorCB != nil {
svc.natsHandlers.asyncErr = svc.conn.ErrorHandler()
if svc.natsHandlers.asyncErr != nil {
svc.conn.SetErrorHandler(func(c *nats.Conn, s *nats.Subscription, err error) {
if !svc.matchSubscriptionSubject(s.Subject) {
svc.natsHandlers.asyncErr(c, s, err)
Expand Down

0 comments on commit d3ae7e5

Please sign in to comment.