|
|
@@ -114,6 +114,22 @@ func (b *InproxyBrokerClientManager) TacticsApplied() error {
|
|
|
return errors.Trace(b.reset(resetBrokerClientReasonTacticsApplied))
|
|
|
}
|
|
|
|
|
|
+// NetworkChanged is called when the active network changes, to trigger a
|
|
|
+// broker client reset.
|
|
|
+func (b *InproxyBrokerClientManager) NetworkChanged() error {
|
|
|
+
|
|
|
+ b.mutex.Lock()
|
|
|
+ defer b.mutex.Unlock()
|
|
|
+
|
|
|
+ // Don't reset when not yet initialized; b.brokerClientInstance is
|
|
|
+ // initialized only on demand.
|
|
|
+ if b.brokerClientInstance == nil {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+
|
|
|
+ return errors.Trace(b.reset(resetBrokerClientReasonNetworkChanged))
|
|
|
+}
|
|
|
+
|
|
|
// GetBrokerClient returns the current, shared broker client and its
|
|
|
// corresponding dial parametrers (for metrics logging). If there is no
|
|
|
// current broker client, if the network ID differs from the network ID
|
|
|
@@ -195,6 +211,7 @@ type resetBrokerClientReason int
|
|
|
const (
|
|
|
resetBrokerClientReasonInit resetBrokerClientReason = iota + 1
|
|
|
resetBrokerClientReasonTacticsApplied
|
|
|
+ resetBrokerClientReasonNetworkChanged
|
|
|
resetBrokerClientReasonRoundTripperFailed
|
|
|
resetBrokerClientReasonRoundNoMatch
|
|
|
)
|
|
|
@@ -220,7 +237,8 @@ func (b *InproxyBrokerClientManager) reset(reason resetBrokerClientReason) error
|
|
|
|
|
|
switch reason {
|
|
|
case resetBrokerClientReasonInit,
|
|
|
- resetBrokerClientReasonTacticsApplied:
|
|
|
+ resetBrokerClientReasonTacticsApplied,
|
|
|
+ resetBrokerClientReasonNetworkChanged:
|
|
|
b.brokerSelectCount = 0
|
|
|
|
|
|
case resetBrokerClientReasonRoundTripperFailed,
|