You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+4-5Lines changed: 4 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -98,7 +98,7 @@ The `sdk_key` is used to compose the outbound HTTP request to the default datafi
98
98
You can provide an initial datafile to bootstrap the `DataFileProjectConfig` so that it can be used immediately. The initial datafile also serves as a fallback datafile if HTTP connection cannot be established. The initial datafile will be discarded after the first successful datafile poll.
99
99
100
100
**polling_interval**
101
-
The polling_interval is used to specify a fixed delay in seconds between consecutive HTTP requests for the datafile.
101
+
The polling interval is used to specify a fixed delay between consecutive HTTP requests for the datafile. Valid duration is between 1 and 2592000 seconds. Default is 5 minutes.
102
102
103
103
**url_template**
104
104
A string with placeholder `{sdk_key}` can be provided so that this template along with the provided `sdk_key` is used to form the target URL.
@@ -107,7 +107,7 @@ A string with placeholder `{sdk_key}` can be provided so that this template alon
107
107
Boolean flag used to start the `AsyncScheduler` for datafile polling if set to `True`.
108
108
109
109
**blocking_timeout**
110
-
Maximum time in seconds to block the `get_config` call until config has been initialized.
110
+
The blocking timeout period is used to specify a maximum time to wait for initial bootstrapping. Valid blocking timeout period is between 1 and 2592000 seconds. Default is 15 seconds.
111
111
112
112
You may also provide your own logger, error handler, or notification center.
Copy file name to clipboardExpand all lines: spec/config_manager/http_project_config_manager_spec.rb
+77Lines changed: 77 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -224,6 +224,7 @@
224
224
sdk_key: 'QBw9gFM8oTn7ogY9ANCC1z',
225
225
datafile: config_body_JSON,
226
226
polling_interval: 1,
227
+
blocking_timeout: 2,
227
228
notification_center: notification_center,
228
229
logger: spy_logger
229
230
)
@@ -291,4 +292,80 @@
291
292
expect(spy_logger).tohave_received(:log).once.with(Logger::ERROR,'Must provide at least one of sdk_key or url.')
292
293
end
293
294
end
295
+
296
+
describe'.polling_interval'do
297
+
it'should log an error when polling_interval is nil'do
298
+
Optimizely::HTTPProjectConfigManager.new(
299
+
sdk_key: 'sdk_key',
300
+
url: nil,
301
+
polling_interval: nil,
302
+
blocking_timeout: 5,
303
+
error_handler: error_handler,
304
+
logger: spy_logger
305
+
)
306
+
expect(spy_logger).tohave_received(:log).once.with(Logger::DEBUG,'Polling interval is not provided. Defaulting to 300 seconds.')
307
+
end
308
+
309
+
it'should log an error when polling_interval has invalid type'do
310
+
Optimizely::HTTPProjectConfigManager.new(
311
+
sdk_key: 'sdk_key',
312
+
url: nil,
313
+
polling_interval: true,
314
+
blocking_timeout: 5,
315
+
error_handler: error_handler,
316
+
logger: spy_logger
317
+
)
318
+
expect(spy_logger).tohave_received(:log).once.with(Logger::ERROR,"Polling interval 'true' has invalid type. Defaulting to 300 seconds.")
319
+
end
320
+
321
+
it'should log an error when polling_interval has invalid range'do
322
+
Optimizely::HTTPProjectConfigManager.new(
323
+
sdk_key: 'sdk_key',
324
+
url: nil,
325
+
polling_interval: 999_999_999_999_999_999,
326
+
blocking_timeout: 5,
327
+
error_handler: error_handler,
328
+
logger: spy_logger
329
+
)
330
+
expect(spy_logger).tohave_received(:log).once.with(Logger::DEBUG,"Polling interval '999999999999999999' has invalid range. Defaulting to 300 seconds.")
331
+
end
332
+
end
333
+
334
+
describe'.blocking_timeout'do
335
+
it'should log an error when blocking_timeout is nil'do
336
+
Optimizely::HTTPProjectConfigManager.new(
337
+
sdk_key: 'sdk_key',
338
+
url: nil,
339
+
polling_interval: 5,
340
+
blocking_timeout: nil,
341
+
error_handler: error_handler,
342
+
logger: spy_logger
343
+
)
344
+
expect(spy_logger).tohave_received(:log).once.with(Logger::DEBUG,'Blocking timeout is not provided. Defaulting to 15 seconds.')
345
+
end
346
+
347
+
it'should log an error when blocking_timeout has invalid type'do
348
+
Optimizely::HTTPProjectConfigManager.new(
349
+
sdk_key: 'sdk_key',
350
+
url: nil,
351
+
polling_interval: 5,
352
+
blocking_timeout: true,
353
+
error_handler: error_handler,
354
+
logger: spy_logger
355
+
)
356
+
expect(spy_logger).tohave_received(:log).once.with(Logger::ERROR,"Blocking timeout 'true' has invalid type. Defaulting to 15 seconds.")
357
+
end
358
+
359
+
it'should log an error when blocking_timeout has invalid range'do
360
+
Optimizely::HTTPProjectConfigManager.new(
361
+
sdk_key: 'sdk_key',
362
+
url: nil,
363
+
polling_interval: 5,
364
+
blocking_timeout: 999_999_999_999_999_999,
365
+
error_handler: error_handler,
366
+
logger: spy_logger
367
+
)
368
+
expect(spy_logger).tohave_received(:log).once.with(Logger::DEBUG,"Blocking timeout '999999999999999999' has invalid range. Defaulting to 15 seconds.")
0 commit comments