flipt_client 0.2.0 → 0.4.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: e8bc0c05bef4e63e44af80fc645966860d85d2d67955d286395b86db656813e7
4
- data.tar.gz: bc31ef92a86f73ae137e187a5fb3a99720ac18de2ccb64da0c2a1b562f886a43
3
+ metadata.gz: '09abc2939bc09022a7228b96b686889ea5074be8dab844f7e68c2e5691d6ba5d'
4
+ data.tar.gz: 2c2f983efd9e8ae01e78688662cfe692c91e80f0d2099b3412906a8e624cbc1c
5
5
  SHA512:
6
- metadata.gz: fd61d88defa40b66c686f1fa14b6df9bb1b578c2dc1a2e8aedc5d218c241fe9678b98002d5873cb50d0d413e46dd333ea3549e4f6bf1dd6c50a3c7699478bfa6
7
- data.tar.gz: 4d8a6c9413564d3fa631541f05fc72dba7bad3d1bacf5b43995e61803b010e7f9517f11a1b3a231ca5fbe9b5fbd06bf47969bc55423003b5af7ff992021130a7
6
+ metadata.gz: 4afcbea261f779d43e374150413bade8e1917f32259e06419bb35b376fe344a59aa7bcacaa443457391da0d165236a49c0d5455e10519bda257d795e3d558a48
7
+ data.tar.gz: ea373fa9331e6eecd4ca7ed53689c222b99a5a76d7b9cc1907fcf52fd6460cd186f0567d9ebf1aa9edc096ec4272c0dcceb683b4103a4a10d41218fedda6248e
Binary file
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * This function will initialize an Engine and return a pointer back to the caller.
10
10
  */
11
- void *initialize_engine(const char *const *namespaces, const char *opts);
11
+ void *initialize_engine(const char *namespace_, const char *opts);
12
12
 
13
13
  /**
14
14
  * # Safety
@@ -31,6 +31,13 @@ const char *evaluate_boolean(void *engine_ptr, const char *evaluation_request);
31
31
  */
32
32
  const char *evaluate_batch(void *engine_ptr, const char *batch_evaluation_request);
33
33
 
34
+ /**
35
+ * # Safety
36
+ *
37
+ * This function will take in a pointer to the engine and return a list of flags for the given namespace.
38
+ */
39
+ const char *list_flags(void *engine_ptr);
40
+
34
41
  /**
35
42
  * # Safety
36
43
  *
Binary file
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Flipt
4
- VERSION = '0.2.0'
4
+ VERSION = '0.4.0'
5
5
  end
data/lib/flipt_client.rb CHANGED
@@ -28,8 +28,8 @@ module Flipt
28
28
 
29
29
  ffi_lib File.expand_path(libfile, __dir__)
30
30
 
31
- # void *initialize_engine(const char *const *namespaces, const char *opts);
32
- attach_function :initialize_engine, %i[pointer string], :pointer
31
+ # void *initialize_engine(const char *namespace, const char *opts);
32
+ attach_function :initialize_engine, %i[string string], :pointer
33
33
  # void destroy_engine(void *engine_ptr);
34
34
  attach_function :destroy_engine, [:pointer], :void
35
35
  # const char *evaluate_variant(void *engine_ptr, const char *evaluation_request);
@@ -38,6 +38,8 @@ module Flipt
38
38
  attach_function :evaluate_boolean, %i[pointer string], :string
39
39
  # const char *evaluate_batch(void *engine_ptr, const char *batch_evaluation_request);
40
40
  attach_function :evaluate_batch, %i[pointer string], :string
41
+ # const char *list_flags(void *engine_ptr);
42
+ attach_function :list_flags, [:pointer], :string
41
43
 
42
44
  # Create a new Flipt client
43
45
  #
@@ -56,13 +58,7 @@ module Flipt
56
58
 
57
59
  opts[:authentication] = authentication.strategy
58
60
 
59
- namespace_list = [namespace]
60
- ns = FFI::MemoryPointer.new(:pointer, namespace_list.size)
61
- namespace_list.each_with_index do |namespace, i|
62
- ns[i].put_pointer(0, FFI::MemoryPointer.from_string(namespace))
63
- end
64
-
65
- @engine = self.class.initialize_engine(ns, opts.to_json)
61
+ @engine = self.class.initialize_engine(namespace, opts.to_json)
66
62
  ObjectSpace.define_finalizer(self, self.class.finalize(@engine))
67
63
  end
68
64
 
@@ -75,9 +71,7 @@ module Flipt
75
71
  # @param evaluation_request [Hash] evaluation request
76
72
  # @option evaluation_request [String] :entity_id entity id
77
73
  # @option evaluation_request [String] :flag_key flag key
78
- # @option evaluation_request [String] :namespace_key override namespace key
79
74
  def evaluate_variant(evaluation_request = {})
80
- evaluation_request[:namespace_key] = @namespace
81
75
  validate_evaluation_request(evaluation_request)
82
76
  resp = self.class.evaluate_variant(@engine, evaluation_request.to_json)
83
77
  JSON.parse(resp)
@@ -88,9 +82,7 @@ module Flipt
88
82
  # @param evaluation_request [Hash] evaluation request
89
83
  # @option evaluation_request [String] :entity_id entity id
90
84
  # @option evaluation_request [String] :flag_key flag key
91
- # @option evaluation_request [String] :namespace_key override namespace key
92
85
  def evaluate_boolean(evaluation_request = {})
93
- evaluation_request[:namespace_key] = @namespace
94
86
  validate_evaluation_request(evaluation_request)
95
87
  resp = self.class.evaluate_boolean(@engine, evaluation_request.to_json)
96
88
  JSON.parse(resp)
@@ -101,10 +93,8 @@ module Flipt
101
93
  # @param batch_evaluation_request [Array<Hash>] batch evaluation request
102
94
  # - :entity_id [String] entity id
103
95
  # - :flag_key [String] flag key
104
- # - :namespace_key [String] override namespace key
105
96
  def evaluate_batch(batch_evaluation_request = [])
106
97
  for request in batch_evaluation_request do
107
- request[:namespace_key] = @namespace
108
98
  validate_evaluation_request(request)
109
99
  end
110
100
 
@@ -112,12 +102,16 @@ module Flipt
112
102
  JSON.parse(resp)
113
103
  end
114
104
 
105
+ # List all flags in the namespace
106
+ def list_flags
107
+ resp = self.class.list_flags(@engine)
108
+ JSON.parse(resp)
109
+ end
110
+
115
111
  private
116
112
  def validate_evaluation_request(evaluation_request)
117
113
  if evaluation_request[:entity_id].nil? || evaluation_request[:entity_id].empty?
118
114
  raise ArgumentError, 'entity_id is required'
119
- elsif evaluation_request[:namespace_key].nil? || evaluation_request[:namespace_key].empty?
120
- raise ArgumentError, 'namespace_key is required'
121
115
  elsif evaluation_request[:flag_key].nil? || evaluation_request[:flag_key].empty?
122
116
  raise ArgumentError, 'flag_key is required'
123
117
  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.2.0
4
+ version: 0.4.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-02-14 00:00:00.000000000 Z
11
+ date: 2024-03-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Flipt Client Evaluation SDK
14
14
  email: