flipt_client 0.3.0 → 0.4.1
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 +4 -4
- data/lib/ext/darwin_arm64/libfliptengine.dylib +0 -0
- data/lib/ext/darwin_arm64/libfliptengine.rlib +0 -0
- data/lib/ext/linux_arm64/libfliptengine.rlib +0 -0
- data/lib/ext/linux_arm64/libfliptengine.so +0 -0
- data/lib/ext/linux_x86_64/flipt_engine.h +16 -1
- data/lib/ext/linux_x86_64/libfliptengine.rlib +0 -0
- data/lib/ext/linux_x86_64/libfliptengine.so +0 -0
- data/lib/flipt_client/version.rb +1 -1
- data/lib/flipt_client.rb +24 -24
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b215784ecdfee2e32670729baa30065fa62cb5a15892b771be440f23a59cf369
|
|
4
|
+
data.tar.gz: 3bf57a74117b84e369de9ebc02060c56ca3a4c1418e1a1ac103f98ec14d03918
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9c6a4f7da51c788a3162531ca0d71375f2c831c23577e8f6eb09a0b8bf937209f72e8310918b06a750b60cedf21b74cd41aae8e64a3c9b885d0778b23ffd737e
|
|
7
|
+
data.tar.gz: 124eac66ca2f98e1fd42fded512d6cf46bdc1e0d6b945ee45539c05eb6f4a0ca15e89f183bc8ae00fd9997fa3af84d7f018083323c6cc4019ade59b8c314ab89
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
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 *
|
|
11
|
+
void *initialize_engine(const char *namespace_, const char *opts);
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* # Safety
|
|
@@ -31,9 +31,24 @@ 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
|
*
|
|
37
44
|
* This function will free the memory occupied by the engine.
|
|
38
45
|
*/
|
|
39
46
|
void destroy_engine(void *engine_ptr);
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* # Safety
|
|
50
|
+
*
|
|
51
|
+
* This function will take in a pointer to the string and free the memory.
|
|
52
|
+
* See Rust the safety section in CString::from_raw.
|
|
53
|
+
*/
|
|
54
|
+
void destroy_string(char *ptr);
|
|
Binary file
|
|
Binary file
|
data/lib/flipt_client/version.rb
CHANGED
data/lib/flipt_client.rb
CHANGED
|
@@ -28,16 +28,20 @@ module Flipt
|
|
|
28
28
|
|
|
29
29
|
ffi_lib File.expand_path(libfile, __dir__)
|
|
30
30
|
|
|
31
|
-
# void *initialize_engine(const char *
|
|
32
|
-
attach_function :initialize_engine, %i[
|
|
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);
|
|
36
|
-
attach_function :evaluate_variant, %i[pointer string], :
|
|
36
|
+
attach_function :evaluate_variant, %i[pointer string], :strptr
|
|
37
37
|
# const char *evaluate_boolean(void *engine_ptr, const char *evaluation_request);
|
|
38
|
-
attach_function :evaluate_boolean, %i[pointer string], :
|
|
38
|
+
attach_function :evaluate_boolean, %i[pointer string], :strptr
|
|
39
39
|
# const char *evaluate_batch(void *engine_ptr, const char *batch_evaluation_request);
|
|
40
|
-
attach_function :evaluate_batch, %i[pointer string], :
|
|
40
|
+
attach_function :evaluate_batch, %i[pointer string], :strptr
|
|
41
|
+
# const char *list_flags(void *engine_ptr);
|
|
42
|
+
attach_function :list_flags, [:pointer], :strptr
|
|
43
|
+
# void destroy_string(const char *ptr);
|
|
44
|
+
attach_function :destroy_string, [:pointer], :void
|
|
41
45
|
|
|
42
46
|
# Create a new Flipt client
|
|
43
47
|
#
|
|
@@ -56,13 +60,7 @@ module Flipt
|
|
|
56
60
|
|
|
57
61
|
opts[:authentication] = authentication.strategy
|
|
58
62
|
|
|
59
|
-
|
|
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)
|
|
63
|
+
@engine = self.class.initialize_engine(namespace, opts.to_json)
|
|
66
64
|
ObjectSpace.define_finalizer(self, self.class.finalize(@engine))
|
|
67
65
|
end
|
|
68
66
|
|
|
@@ -75,11 +73,10 @@ module Flipt
|
|
|
75
73
|
# @param evaluation_request [Hash] evaluation request
|
|
76
74
|
# @option evaluation_request [String] :entity_id entity id
|
|
77
75
|
# @option evaluation_request [String] :flag_key flag key
|
|
78
|
-
# @option evaluation_request [String] :namespace_key override namespace key
|
|
79
76
|
def evaluate_variant(evaluation_request = {})
|
|
80
|
-
evaluation_request[:namespace_key] = @namespace
|
|
81
77
|
validate_evaluation_request(evaluation_request)
|
|
82
|
-
resp = self.class.evaluate_variant(@engine, evaluation_request.to_json)
|
|
78
|
+
resp, ptr = self.class.evaluate_variant(@engine, evaluation_request.to_json)
|
|
79
|
+
ptr = FFI::AutoPointer.new(ptr, EvaluationClient.method(:destroy_string))
|
|
83
80
|
JSON.parse(resp)
|
|
84
81
|
end
|
|
85
82
|
|
|
@@ -88,27 +85,32 @@ module Flipt
|
|
|
88
85
|
# @param evaluation_request [Hash] evaluation request
|
|
89
86
|
# @option evaluation_request [String] :entity_id entity id
|
|
90
87
|
# @option evaluation_request [String] :flag_key flag key
|
|
91
|
-
# @option evaluation_request [String] :namespace_key override namespace key
|
|
92
88
|
def evaluate_boolean(evaluation_request = {})
|
|
93
|
-
evaluation_request[:namespace_key] = @namespace
|
|
94
89
|
validate_evaluation_request(evaluation_request)
|
|
95
|
-
resp = self.class.evaluate_boolean(@engine, evaluation_request.to_json)
|
|
90
|
+
resp, ptr = self.class.evaluate_boolean(@engine, evaluation_request.to_json)
|
|
91
|
+
ptr = FFI::AutoPointer.new(ptr, EvaluationClient.method(:destroy_string))
|
|
96
92
|
JSON.parse(resp)
|
|
97
93
|
end
|
|
98
|
-
|
|
94
|
+
|
|
99
95
|
# Evaluate a batch of flags for a given request
|
|
100
96
|
#
|
|
101
97
|
# @param batch_evaluation_request [Array<Hash>] batch evaluation request
|
|
102
98
|
# - :entity_id [String] entity id
|
|
103
99
|
# - :flag_key [String] flag key
|
|
104
|
-
# - :namespace_key [String] override namespace key
|
|
105
100
|
def evaluate_batch(batch_evaluation_request = [])
|
|
106
101
|
for request in batch_evaluation_request do
|
|
107
|
-
request[:namespace_key] = @namespace
|
|
108
102
|
validate_evaluation_request(request)
|
|
109
103
|
end
|
|
110
104
|
|
|
111
|
-
resp = self.class.evaluate_batch(@engine, batch_evaluation_request.to_json)
|
|
105
|
+
resp, ptr = self.class.evaluate_batch(@engine, batch_evaluation_request.to_json)
|
|
106
|
+
ptr = FFI::AutoPointer.new(ptr, EvaluationClient.method(:destroy_string))
|
|
107
|
+
JSON.parse(resp)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# List all flags in the namespace
|
|
111
|
+
def list_flags
|
|
112
|
+
resp, ptr = self.class.list_flags(@engine)
|
|
113
|
+
ptr = FFI::AutoPointer.new(ptr, EvaluationClient.method(:destroy_string))
|
|
112
114
|
JSON.parse(resp)
|
|
113
115
|
end
|
|
114
116
|
|
|
@@ -116,8 +118,6 @@ module Flipt
|
|
|
116
118
|
def validate_evaluation_request(evaluation_request)
|
|
117
119
|
if evaluation_request[:entity_id].nil? || evaluation_request[:entity_id].empty?
|
|
118
120
|
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
121
|
elsif evaluation_request[:flag_key].nil? || evaluation_request[:flag_key].empty?
|
|
122
122
|
raise ArgumentError, 'flag_key is required'
|
|
123
123
|
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.
|
|
4
|
+
version: 0.4.1
|
|
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-
|
|
11
|
+
date: 2024-03-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Flipt Client Evaluation SDK
|
|
14
14
|
email:
|