flipt_client 0.11.0 → 0.12.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d629e8ecefa5e1a68f25ebae475ae3238af2fc9eef9331f5dd6a674e68d50c6
4
- data.tar.gz: 775349fdd7616a11cb77ad1e89dac5812ae7aa628c526183a14fc109f6f649de
3
+ metadata.gz: 20580ac221c34294feeb51f8a9198980d476fce87e8aafd50c9ac077df3ad498
4
+ data.tar.gz: f8342ae2127c00ca52b3f593bc094987050df738edf14567d4f5b988e22d4f47
5
5
  SHA512:
6
- metadata.gz: 997654812c0accecbd6ba79c16d7dce379785734abc7dbdaa4c79ed2c9872b3ec8b65595ca01da6ce63e672144ca98f2b22745b166cb5070b95e23b35a0550ad
7
- data.tar.gz: b3ebea80facd6b4634f1ca69fd9216ae459884b07c043eb4409e18bdf8b1c98338c47e46acf3996c7b8f38cd9be413252c3c6ce79928e7be59aa8988893c0ff0
6
+ metadata.gz: ab287927c314e8c00a930ca7bfb92eed25788ee82d9d600e2eabb564abba98e33e4af3bc0fa5706ff4a12c8e398c732db1b50697799bccd28d14cbaf59e0fafb
7
+ data.tar.gz: cfd783d6e15b9fb5613f1c793d06d965330f574491fd2046a284fc579542cef57ffb49b157e6db7deaaf032eedaa1ae694d68682dba17752bd10834530aab1b6
data/README.md CHANGED
@@ -10,6 +10,28 @@ The `flipt-client-ruby` library contains the Ruby source code for the Flipt [cli
10
10
  gem install flipt_client
11
11
  ```
12
12
 
13
+ ## How Does It Work?
14
+
15
+ The `flipt-client-ruby` library is a wrapper around the [flipt-engine-ffi](https://github.com/flipt-io/flipt-client-sdks/tree/main/flipt-engine-ffi) library.
16
+
17
+ All evaluation happens within the SDK, using the shared library built from the [flipt-engine-ffi](https://github.com/flipt-io/flipt-client-sdks/tree/main/flipt-engine-ffi) library.
18
+
19
+ Because the evaluation happens within the SDK, the SDKs can be used in environments where the Flipt server is not available or reachable after the initial data is fetched.
20
+
21
+ ## Data Fetching
22
+
23
+ Upon instantiation, the `flipt-client-ruby` library will fetch the flag state from the Flipt server and store it in memory. This means that the first time you use the SDK, it will make a request to the Flipt server.
24
+
25
+ ### Polling (Default)
26
+
27
+ By default, the SDK will poll the Flipt server for new flag state at a regular interval. This interval can be configured using the `update_interval` option when constructing a client. The default interval is 120 seconds.
28
+
29
+ ### Streaming (Flipt Cloud Only)
30
+
31
+ [Flipt Cloud](https://flipt.io/cloud) users can use the `streaming` fetch method to stream flag state changes from the Flipt server to the SDK.
32
+
33
+ When in streaming mode, the SDK will connect to the Flipt server and open a persistent connection that will remain open until the client is closed. The SDK will then receive flag state changes in real-time.
34
+
13
35
  ## Supported Architectures
14
36
 
15
37
  This SDK currently supports the following OSes/architectures:
@@ -61,11 +83,12 @@ puts resp
61
83
  The `Flipt::EvaluationClient` constructor accepts two optional arguments:
62
84
 
63
85
  - `namespace`: The namespace to fetch flag state from. If not provided, the client will default to the `default` namespace.
64
- - `engine_opts`: A hash that supports several options for the client. The structure is:
86
+ - `opts`: A hash that supports several options for the client. The structure is:
65
87
  - `url`: The URL of the upstream Flipt instance. If not provided, the client will default to `http://localhost:8080`.
66
88
  - `update_interval`: The interval (in seconds) in which to fetch new flag state. If not provided, the client will default to 120 seconds.
67
89
  - `authentication`: The authentication strategy to use when communicating with the upstream Flipt instance. If not provided, the client will default to no authentication. See the [Authentication](#authentication) section for more information.
68
90
  - `reference`: The [reference](https://docs.flipt.io/guides/user/using-references) to use when fetching flag state. If not provided, reference will not be used.
91
+ - `fetch_mode`: The fetch mode to use when fetching flag state. If not provided, the client will default to polling.
69
92
 
70
93
  ### Authentication
71
94
 
Binary file
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Flipt
4
- VERSION = '0.11.0'
4
+ VERSION = '0.12.0'
5
5
  end
data/lib/flipt_client.rb CHANGED
@@ -55,6 +55,8 @@ module Flipt
55
55
  # @option opts [AuthenticationStrategy] :authentication strategy to authenticate with Flipt
56
56
  # @option opts [Integer] :update_interval interval in seconds to update the cache
57
57
  # @option opts [String] :reference reference to use for namespace data
58
+ # @option opts [Symbol] :fetch_mode fetch mode to use for the client (:polling or :streaming).
59
+ # Note: Streaming is currently only supported when using the SDK with Flipt Cloud (https://flipt.io/cloud).
58
60
  def initialize(namespace = 'default', opts = {})
59
61
  @namespace = namespace
60
62
 
@@ -65,6 +67,11 @@ module Flipt
65
67
  'invalid authentication strategy'
66
68
  end
67
69
 
70
+ fetch_mode = opts.fetch(:fetch_mode, :polling)
71
+ unless %i[polling streaming].include?(fetch_mode)
72
+ raise ArgumentError, 'invalid fetch mode'
73
+ end
74
+
68
75
  opts[:authentication] = authentication.strategy
69
76
 
70
77
  @engine = self.class.initialize_engine(namespace, opts.to_json)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flipt_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Flipt Devs
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-10-16 00:00:00.000000000 Z
11
+ date: 2024-10-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Flipt Client Evaluation SDK
14
14
  email: