MCPcopy
hub / github.com/nats-io/nats.go / processAuthError

Method processAuthError

nats.go:3952–3967  ·  view source on GitHub ↗

processAuthError generally processing for auth errors. We want to do retries unless we get the same error again. This allows us for instance to swap credentials and have the app reconnect, but if nothing is changing we should bail. This function will return true if the connection should be closed, f

(err error)

Source from the content-addressed store, hash-verified

3950// This function will return true if the connection should be closed, false otherwise.
3951// Connection lock is held on entry
3952func (nc *Conn) processAuthError(err error) bool {
3953 nc.err = err
3954 if !nc.initc {
3955 if asyncErrorCB := nc.Opts.AsyncErrorCB; asyncErrorCB != nil {
3956 nc.ach.push(func() { asyncErrorCB(nc, nil, err) })
3957 }
3958 }
3959 // We should give up if we tried twice on this server and got the
3960 // same error. This behavior can be modified using IgnoreAuthErrorAbort.
3961 if nc.current.lastErr == err && !nc.Opts.IgnoreAuthErrorAbort {
3962 nc.ar = true
3963 } else {
3964 nc.current.lastErr = err
3965 }
3966 return nc.ar
3967}
3968
3969// flusher is a separate Go routine that will process flush requests for the write
3970// bufio. This allows coalescing of writes to the underlying socket.

Callers 2

sendConnectMethod · 0.95
processErrMethod · 0.95

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected