@gearbox-protocol/sdk 9.1.4 → 9.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -33,6 +33,7 @@ class RevolverTransport {
|
|
|
33
33
|
#transports;
|
|
34
34
|
#index = 0;
|
|
35
35
|
#config;
|
|
36
|
+
#rotating = false;
|
|
36
37
|
overrides;
|
|
37
38
|
/**
|
|
38
39
|
* Create a new RevolverTransport
|
|
@@ -131,6 +132,11 @@ class RevolverTransport {
|
|
|
131
132
|
if (this.#transports.length === 1) {
|
|
132
133
|
return true;
|
|
133
134
|
}
|
|
135
|
+
if (this.#rotating) {
|
|
136
|
+
this.#logger?.debug("already rotating, skipping");
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
this.#rotating = true;
|
|
134
140
|
this.#logger?.debug(
|
|
135
141
|
{
|
|
136
142
|
reason,
|
|
@@ -154,11 +160,15 @@ class RevolverTransport {
|
|
|
154
160
|
},
|
|
155
161
|
"switched to next transport"
|
|
156
162
|
);
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
163
|
+
try {
|
|
164
|
+
await this.#config.onRotateSuccess?.(
|
|
165
|
+
oldTransportName,
|
|
166
|
+
this.currentTransportName,
|
|
167
|
+
reason
|
|
168
|
+
);
|
|
169
|
+
} catch {
|
|
170
|
+
}
|
|
171
|
+
this.#rotating = false;
|
|
162
172
|
return true;
|
|
163
173
|
} else {
|
|
164
174
|
this.#logger?.warn(
|
|
@@ -171,7 +181,11 @@ class RevolverTransport {
|
|
|
171
181
|
);
|
|
172
182
|
}
|
|
173
183
|
}
|
|
174
|
-
|
|
184
|
+
try {
|
|
185
|
+
await this.#config.onRotateFailed?.(oldTransportName, reason);
|
|
186
|
+
} catch {
|
|
187
|
+
}
|
|
188
|
+
this.#rotating = false;
|
|
175
189
|
return false;
|
|
176
190
|
}
|
|
177
191
|
get currentTransportName() {
|
|
@@ -16,6 +16,7 @@ class RevolverTransport {
|
|
|
16
16
|
#transports;
|
|
17
17
|
#index = 0;
|
|
18
18
|
#config;
|
|
19
|
+
#rotating = false;
|
|
19
20
|
overrides;
|
|
20
21
|
/**
|
|
21
22
|
* Create a new RevolverTransport
|
|
@@ -114,6 +115,11 @@ class RevolverTransport {
|
|
|
114
115
|
if (this.#transports.length === 1) {
|
|
115
116
|
return true;
|
|
116
117
|
}
|
|
118
|
+
if (this.#rotating) {
|
|
119
|
+
this.#logger?.debug("already rotating, skipping");
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
this.#rotating = true;
|
|
117
123
|
this.#logger?.debug(
|
|
118
124
|
{
|
|
119
125
|
reason,
|
|
@@ -137,11 +143,15 @@ class RevolverTransport {
|
|
|
137
143
|
},
|
|
138
144
|
"switched to next transport"
|
|
139
145
|
);
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
146
|
+
try {
|
|
147
|
+
await this.#config.onRotateSuccess?.(
|
|
148
|
+
oldTransportName,
|
|
149
|
+
this.currentTransportName,
|
|
150
|
+
reason
|
|
151
|
+
);
|
|
152
|
+
} catch {
|
|
153
|
+
}
|
|
154
|
+
this.#rotating = false;
|
|
145
155
|
return true;
|
|
146
156
|
} else {
|
|
147
157
|
this.#logger?.warn(
|
|
@@ -154,7 +164,11 @@ class RevolverTransport {
|
|
|
154
164
|
);
|
|
155
165
|
}
|
|
156
166
|
}
|
|
157
|
-
|
|
167
|
+
try {
|
|
168
|
+
await this.#config.onRotateFailed?.(oldTransportName, reason);
|
|
169
|
+
} catch {
|
|
170
|
+
}
|
|
171
|
+
this.#rotating = false;
|
|
158
172
|
return false;
|
|
159
173
|
}
|
|
160
174
|
get currentTransportName() {
|
|
@@ -33,7 +33,7 @@ export interface RevolverTransportConfig {
|
|
|
33
33
|
/**
|
|
34
34
|
* Callback that is called when the transport cannot be rotated
|
|
35
35
|
*/
|
|
36
|
-
onRotateFailed?: (reason?: BaseError) => void | Promise<void>;
|
|
36
|
+
onRotateFailed?: (oldTransportName: string, reason?: BaseError) => void | Promise<void>;
|
|
37
37
|
/**
|
|
38
38
|
* How long, in milliseconds, to wait before try this transport again
|
|
39
39
|
*/
|