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
| enableAnalytics | stream_enabled(true) | Enable analytics. Metrics data is posted every 60s | true |
26
26
27
+
## Client Initialization Options
28
+
The Harness Feature Flags SDK for Ruby provides flexible initialization strategies to accommodate various application requirements. You can choose between an asynchronous (non-blocking) or synchronous (blocking) approach to initialize the SDK.
29
+
30
+
### Asynchronous (Non-Blocking) Initialization
31
+
The SDK can be initialized asynchronously without blocking the main thread or requiring a callback. In this case, defaults will be served until the SDK completes the initialization process.
32
+
33
+
```ruby
34
+
client =CfClient.instance
35
+
client.init(api_key, config)
36
+
37
+
# Will serve default until the SDK completes initialization
38
+
result = client.bool_variation("bool_flag", target, false)
39
+
```
40
+
41
+
### Synchronous (Blocking) Initialization
42
+
43
+
In cases where it's critical to ensure the SDK is initialized before evaluating flags, the SDK offers a synchronous initialization method. This approach blocks the current thread until the SDK is fully initialized or the optional specified timeout (in milliseconds) period elapses.
44
+
45
+
The synchronous method is useful for environments where feature flag decisions are needed before continuing, such as during application startup.
46
+
47
+
You can use the `wait_for_initialization` method, optionally providing a timeout in milliseconds to prevent waiting indefinitely in case of unrecoverable isues, e.g. incorrect API key used.
48
+
49
+
**Usage with a timeout**
50
+
51
+
```ruby
52
+
client =CfClient.instance
53
+
client.init(api_key, config)
54
+
55
+
client.wait_for_initialization
56
+
57
+
result = client.bool_variation("bool_flag", target, false)
58
+
```
59
+
60
+
**Usage without a timeout**
61
+
62
+
```ruby
63
+
client =CfClient.instance
64
+
client.init(api_key, config)
65
+
66
+
client.wait_for_initialization(timeout_ms:3000)
67
+
68
+
result = client.bool_variation("bool_flag", target, false)
69
+
```
70
+
27
71
## Logging Configuration
28
72
You can provide your own logger to the SDK i.e. using the moneta logger we can do this
0 commit comments