ing
This commit is contained in:
parent
750524f29c
commit
68341e3eb5
|
@ -22,6 +22,8 @@ type Connectors struct {
|
|||
Address string `json:"address,omitempty"`
|
||||
LocalAddress net.Addr `json:"-"`
|
||||
|
||||
OnDisconnected func(connector client.Connector) `json:"-"`
|
||||
|
||||
stopChan chan struct{}
|
||||
stopWg sync.WaitGroup
|
||||
|
||||
|
@ -102,6 +104,12 @@ RC_LOOP:
|
|||
|
||||
if 0 >= c.GetReconnectTryTime() {
|
||||
c.reconnectedChan <- nil
|
||||
|
||||
onDisconnected := c.OnDisconnected
|
||||
if nil != onDisconnected {
|
||||
onDisconnected(c)
|
||||
}
|
||||
|
||||
continue RC_LOOP
|
||||
}
|
||||
|
||||
|
@ -118,7 +126,12 @@ RC_LOOP:
|
|||
}
|
||||
time.Sleep(c.GetReconnectInterval())
|
||||
}
|
||||
|
||||
logging.Logger().Debugf("%s reconnecting has been failed", c.logHeader())
|
||||
onDisconnected := c.OnDisconnected
|
||||
if nil != onDisconnected {
|
||||
onDisconnected(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,8 @@ type Connectors struct {
|
|||
// If Proxy is nil or returns a nil *URL, no proxy is used.
|
||||
Proxy func(*http.Request) (*url.URL, error) `json:"-"`
|
||||
|
||||
OnDisconnected func(connector client.Connector) `json:"-"`
|
||||
|
||||
serverURL *url.URL
|
||||
|
||||
stopChan chan struct{}
|
||||
|
@ -139,6 +141,12 @@ RC_LOOP:
|
|||
|
||||
if 0 >= c.GetReconnectTryTime() {
|
||||
c.reconnectedChan <- nil
|
||||
|
||||
onDisconnected := c.OnDisconnected
|
||||
if nil != onDisconnected {
|
||||
onDisconnected(c)
|
||||
}
|
||||
|
||||
continue RC_LOOP
|
||||
}
|
||||
|
||||
|
@ -161,6 +169,11 @@ RC_LOOP:
|
|||
time.Sleep(c.GetReconnectInterval())
|
||||
}
|
||||
logging.Logger().Debugf("%s reconnecting has been failed", c.logHeader())
|
||||
|
||||
onDisconnected := c.OnDisconnected
|
||||
if nil != onDisconnected {
|
||||
onDisconnected(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user