fable 3.1.69 → 3.1.70

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fable",
3
- "version": "3.1.69",
3
+ "version": "3.1.70",
4
4
  "description": "A service dependency injection, configuration and logging library.",
5
5
  "main": "source/Fable.js",
6
6
  "scripts": {
@@ -33,7 +33,7 @@ class FableServiceRestClient extends libFableServiceBase
33
33
  let tmpKeepAlive = this.options.KeepAlive || this.fable.settings.RestClientKeepAlive;
34
34
  if (tmpKeepAlive)
35
35
  {
36
- this.initializeKeepAliveAgent();
36
+ this.initializeKeepAliveAgent(this.options.KeepAliveAgentOptions);
37
37
  }
38
38
  }
39
39
 
@@ -41,10 +41,12 @@ class FableServiceRestClient extends libFableServiceBase
41
41
  * Initialize HTTP keep-alive agents and wire them into prepareRequestOptions.
42
42
  * Creates both an HTTP and HTTPS agent so the correct one is selected per-request
43
43
  * based on the URL protocol.
44
+ *
45
+ * @param {Object} [pAgentOptions] - Additional options passed to the Http/Https Agent constructors (e.g. timeout).
44
46
  */
45
- initializeKeepAliveAgent()
47
+ initializeKeepAliveAgent(pAgentOptions)
46
48
  {
47
- let tmpAgentOptions = { keepAlive: true };
49
+ let tmpAgentOptions = Object.assign({ keepAlive: true }, pAgentOptions);
48
50
 
49
51
  this.httpAgent = new libHttp.Agent(tmpAgentOptions);
50
52
  this.httpsAgent = new libHttps.Agent(tmpAgentOptions);
@@ -180,6 +180,27 @@ suite
180
180
  }
181
181
  );
182
182
  test
183
+ (
184
+ 'Pass additional agent options via KeepAliveAgentOptions.',
185
+ function ()
186
+ {
187
+ let testFable = new libFable();
188
+ let tmpRestClient = testFable.instantiateServiceProvider('RestClient',
189
+ {
190
+ KeepAlive: true,
191
+ KeepAliveAgentOptions: { timeout: 300000 }
192
+ }, 'RestClient-KeepAlive-AgentOpts');
193
+
194
+ Expect(tmpRestClient.httpAgent).to.be.an('object');
195
+ Expect(tmpRestClient.httpsAgent).to.be.an('object');
196
+ Expect(tmpRestClient.httpAgent.keepAlive).to.equal(true);
197
+ Expect(tmpRestClient.httpsAgent.keepAlive).to.equal(true);
198
+ // Verify the custom timeout was passed through
199
+ Expect(tmpRestClient.httpAgent.options.timeout).to.equal(300000);
200
+ Expect(tmpRestClient.httpsAgent.options.timeout).to.equal(300000);
201
+ }
202
+ );
203
+ test
183
204
  (
184
205
  'Do not create agents when KeepAlive is not set.',
185
206
  function ()