flipt_client 0.11.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d629e8ecefa5e1a68f25ebae475ae3238af2fc9eef9331f5dd6a674e68d50c6
4
- data.tar.gz: 775349fdd7616a11cb77ad1e89dac5812ae7aa628c526183a14fc109f6f649de
3
+ metadata.gz: b2e98029e4995b21b27c93e7d8c3083b29a2cfe4f1102b8286a8210066887498
4
+ data.tar.gz: 3c9b1960602c1295b76689fbe84c490dc2b71ba0a205dac8e8b8757fe0c7e801
5
5
  SHA512:
6
- metadata.gz: 997654812c0accecbd6ba79c16d7dce379785734abc7dbdaa4c79ed2c9872b3ec8b65595ca01da6ce63e672144ca98f2b22745b166cb5070b95e23b35a0550ad
7
- data.tar.gz: b3ebea80facd6b4634f1ca69fd9216ae459884b07c043eb4409e18bdf8b1c98338c47e46acf3996c7b8f38cd9be413252c3c6ce79928e7be59aa8988893c0ff0
6
+ metadata.gz: f3a69f54c01bb5d6bd99f14a11f3cb6718448c9ef2b4deb8a991d54c7ca7a3589975d874bc484de07fa407a4ca64a3a7f32278ae0ccd257b6d71f50bfedd5fe2
7
+ data.tar.gz: eb4b8d64a0da38cf548008611cbe2f788658e57e2b4e8057989885de47220cc68ddb6a85747a437781e4e7748f5d2e8914c3f9d89a655f55a3ff72f2cac1a539
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.13.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.13.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-12-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Flipt Client Evaluation SDK
14
14
  email: