flipt_client 0.14.0 → 0.15.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: 3b557abfcc6b932d2df3477574c31e1e3531b723e40c8d4165c896223f0a4e29
4
- data.tar.gz: c4b0100e653392c2b7cf2a2d0706562295e378f042192f71ec2cbe9fb81ca22b
3
+ metadata.gz: ad11b9c66ba85ede2dc4bd1e13ea76625b40b4eb921d0bb905d5d3b575289662
4
+ data.tar.gz: 7a3f3db0ec3da94f946f94491809feaf6aa6a782a7ec843c47ab7c656bd764bc
5
5
  SHA512:
6
- metadata.gz: e678e1267550f6d9a13a5b14b0b1182cb6bc7158f33c15c1eaee7428250ab5975e5f71e3d67d7fd2bdb5979887a959985efdf50009540a873b6126a4804e657a
7
- data.tar.gz: a11c9c16338ba2184feb4e7a39cf7131f28779414b5c86f0b20da0dcbdc926b3afcd1f1ad5e4d66ca2f5cb36f8d9735a037e0732fd37d8da3b045fb710100345
6
+ metadata.gz: 35a4f6593d4b5b0b5eb99e10ce97b63f4a7567767a2a9160e033654d1de56103d3016e86cb517b22cb7c38c9ef7547bdd2f8a35a8c54caadff0d5f765fffcb7f
7
+ data.tar.gz: 85ef57b021d738b87eb72ff66c54932820eb95a1a4d6c931c24cf4ebfa256e9e88c38ee704aad57de08960a8f73c07b94b3ef26692f8768f83079015107335dc
data/README.md CHANGED
@@ -89,6 +89,7 @@ The `Flipt::EvaluationClient` constructor accepts two optional arguments:
89
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.
90
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
91
  - `fetch_mode`: The fetch mode to use when fetching flag state. If not provided, the client will default to polling.
92
+ - `error_strategy`: The error strategy to use when fetching flag state. If not provide, the client will be default to fail. See the [Error Strategies](#error-strategies) section for more information.
92
93
 
93
94
  ### Authentication
94
95
 
@@ -98,6 +99,13 @@ The `FliptEvaluationClient` supports the following authentication strategies:
98
99
  - [Client Token Authentication](https://docs.flipt.io/authentication/using-tokens)
99
100
  - [JWT Authentication](https://docs.flipt.io/authentication/using-jwts)
100
101
 
102
+ ### Error Strategies
103
+
104
+ The client supports the following error strategies:
105
+
106
+ - `fail`: The client will throw an error if the flag state cannot be fetched. This is the default behavior.
107
+ - `fallback`: The client will maintain the last known good state and use that state for evaluation in case of an error.
108
+
101
109
  ## Load Test
102
110
 
103
111
  1. To run the load test, you'll need to have Flipt running locally. You can do this by running the following command from the root of the repository:
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Flipt
4
- VERSION = '0.14.0'
4
+ VERSION = '0.15.0'
5
5
  end
data/lib/flipt_client.rb CHANGED
@@ -57,22 +57,13 @@ module Flipt
57
57
  # @option opts [String] :reference reference to use for namespace data
58
58
  # @option opts [Symbol] :fetch_mode fetch mode to use for the client (:polling or :streaming).
59
59
  # Note: Streaming is currently only supported when using the SDK with Flipt Cloud (https://flipt.io/cloud).
60
+ # @option opts [Symbol] :error_strategy error strategy to use for the client (:fail or :fallback).
60
61
  def initialize(namespace = 'default', opts = {})
61
62
  @namespace = namespace
62
63
 
63
- # set default no auth if not provided
64
- authentication = opts.fetch(:authentication, NoAuthentication.new)
65
- unless authentication.is_a?(AuthenticationStrategy)
66
- raise ArgumentError,
67
- 'invalid authentication strategy'
68
- end
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
-
75
- opts[:authentication] = authentication.strategy
64
+ opts[:authentication] = validate_authentication(opts.fetch(:authentication, NoAuthentication.new))
65
+ opts[:fetch_mode] = validate_fetch_mode(opts.fetch(:fetch_mode, :polling))
66
+ opts[:error_strategy] = validate_error_strategy(opts.fetch(:error_strategy, :fail))
76
67
 
77
68
  @engine = self.class.initialize_engine(namespace, opts.to_json)
78
69
  ObjectSpace.define_finalizer(self, self.class.finalize(@engine))
@@ -149,5 +140,23 @@ module Flipt
149
140
  raise ArgumentError, 'flag_key is required'
150
141
  end
151
142
  end
143
+
144
+ def validate_authentication(authentication)
145
+ return authentication.strategy if authentication.is_a?(AuthenticationStrategy)
146
+
147
+ raise ArgumentError, 'invalid authentication strategy'
148
+ end
149
+
150
+ def validate_fetch_mode(fetch_mode)
151
+ return fetch_mode if %i[polling streaming].include?(fetch_mode)
152
+
153
+ raise ArgumentError, 'invalid fetch mode'
154
+ end
155
+
156
+ def validate_error_strategy(error_strategy)
157
+ return error_strategy if %i[fail fallback].include?(error_strategy)
158
+
159
+ raise ArgumentError, 'invalid error strategy'
160
+ end
152
161
  end
153
162
  end
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.14.0
4
+ version: 0.15.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: 2025-02-14 00:00:00.000000000 Z
11
+ date: 2025-02-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Flipt Client Evaluation SDK
14
14
  email: