flipt_client 0.0.5 → 0.2.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 +4 -4
- data/README.md +3 -1
- 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 +7 -0
- data/lib/ext/linux_x86_64/libfliptengine.rlib +0 -0
- data/lib/ext/linux_x86_64/libfliptengine.so +0 -0
- data/lib/flipt_client/models.rb +39 -0
- data/lib/flipt_client/version.rb +1 -1
- data/lib/flipt_client.rb +27 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8bc0c05bef4e63e44af80fc645966860d85d2d67955d286395b86db656813e7
|
4
|
+
data.tar.gz: bc31ef92a86f73ae137e187a5fb3a99720ac18de2ccb64da0c2a1b562f886a43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd61d88defa40b66c686f1fa14b6df9bb1b578c2dc1a2e8aedc5d218c241fe9678b98002d5873cb50d0d413e46dd333ea3549e4f6bf1dd6c50a3c7699478bfa6
|
7
|
+
data.tar.gz: 4d8a6c9413564d3fa631541f05fc72dba7bad3d1bacf5b43995e61803b010e7f9517f11a1b3a231ca5fbe9b5fbd06bf47969bc55423003b5af7ff992021130a7
|
data/README.md
CHANGED
@@ -33,7 +33,9 @@ require 'flipt_client'
|
|
33
33
|
# {
|
34
34
|
# "url": "http://localhost:8080",
|
35
35
|
# "update_interval": 120,
|
36
|
-
# "
|
36
|
+
# "authentication": {
|
37
|
+
# "client_token": "secret"
|
38
|
+
# }
|
37
39
|
# }
|
38
40
|
#
|
39
41
|
# You can replace the url with where your upstream Flipt instance points to, the update interval for how long you are willing
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -24,6 +24,13 @@ const char *evaluate_variant(void *engine_ptr, const char *evaluation_request);
|
|
24
24
|
*/
|
25
25
|
const char *evaluate_boolean(void *engine_ptr, const char *evaluation_request);
|
26
26
|
|
27
|
+
/**
|
28
|
+
* # Safety
|
29
|
+
*
|
30
|
+
* This function will take in a pointer to the engine and return a batch evaluation response.
|
31
|
+
*/
|
32
|
+
const char *evaluate_batch(void *engine_ptr, const char *batch_evaluation_request);
|
33
|
+
|
27
34
|
/**
|
28
35
|
* # Safety
|
29
36
|
*
|
Binary file
|
Binary file
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Flipt
|
4
|
+
class AuthenticationStrategy
|
5
|
+
def strategy
|
6
|
+
raise NotImplementedError
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class NoAuthentication < AuthenticationStrategy
|
11
|
+
def strategy
|
12
|
+
nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class ClientTokenAuthentication < AuthenticationStrategy
|
17
|
+
def initialize(token)
|
18
|
+
@token = token
|
19
|
+
end
|
20
|
+
|
21
|
+
def strategy
|
22
|
+
{
|
23
|
+
client_token: @token
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class JWTAuthentication < AuthenticationStrategy
|
29
|
+
def initialize(token)
|
30
|
+
@token = token
|
31
|
+
end
|
32
|
+
|
33
|
+
def strategy
|
34
|
+
{
|
35
|
+
jwt_token: @token
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/flipt_client/version.rb
CHANGED
data/lib/flipt_client.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'flipt_client/version'
|
4
|
+
require 'flipt_client/models'
|
4
5
|
require 'ffi'
|
5
6
|
require 'json'
|
6
7
|
|
@@ -35,17 +36,26 @@ module Flipt
|
|
35
36
|
attach_function :evaluate_variant, %i[pointer string], :string
|
36
37
|
# const char *evaluate_boolean(void *engine_ptr, const char *evaluation_request);
|
37
38
|
attach_function :evaluate_boolean, %i[pointer string], :string
|
39
|
+
# const char *evaluate_batch(void *engine_ptr, const char *batch_evaluation_request);
|
40
|
+
attach_function :evaluate_batch, %i[pointer string], :string
|
38
41
|
|
39
42
|
# Create a new Flipt client
|
40
43
|
#
|
41
44
|
# @param namespace [String] namespace
|
42
45
|
# @param opts [Hash] options
|
43
46
|
# @option opts [String] :url Flipt server url
|
44
|
-
# @option opts [
|
47
|
+
# @option opts [AuthenticationStrategy] :authentication strategy to authenticate with Flipt
|
45
48
|
# @option opts [Integer] :update_interval interval in seconds to update the cache
|
46
49
|
# @option opts [String] :reference reference to use for namespace data
|
47
50
|
def initialize(namespace = 'default', opts = {})
|
48
51
|
@namespace = namespace
|
52
|
+
|
53
|
+
# set default no auth if not provided
|
54
|
+
authentication = opts.fetch(:authentication, Flipt::NoAuthentication.new)
|
55
|
+
raise ArgumentError, "invalid authentication strategy" unless authentication && authentication.is_a?(Flipt::AuthenticationStrategy)
|
56
|
+
|
57
|
+
opts[:authentication] = authentication.strategy
|
58
|
+
|
49
59
|
namespace_list = [namespace]
|
50
60
|
ns = FFI::MemoryPointer.new(:pointer, namespace_list.size)
|
51
61
|
namespace_list.each_with_index do |namespace, i|
|
@@ -85,6 +95,22 @@ module Flipt
|
|
85
95
|
resp = self.class.evaluate_boolean(@engine, evaluation_request.to_json)
|
86
96
|
JSON.parse(resp)
|
87
97
|
end
|
98
|
+
|
99
|
+
# Evaluate a batch of flags for a given request
|
100
|
+
#
|
101
|
+
# @param batch_evaluation_request [Array<Hash>] batch evaluation request
|
102
|
+
# - :entity_id [String] entity id
|
103
|
+
# - :flag_key [String] flag key
|
104
|
+
# - :namespace_key [String] override namespace key
|
105
|
+
def evaluate_batch(batch_evaluation_request = [])
|
106
|
+
for request in batch_evaluation_request do
|
107
|
+
request[:namespace_key] = @namespace
|
108
|
+
validate_evaluation_request(request)
|
109
|
+
end
|
110
|
+
|
111
|
+
resp = self.class.evaluate_batch(@engine, batch_evaluation_request.to_json)
|
112
|
+
JSON.parse(resp)
|
113
|
+
end
|
88
114
|
|
89
115
|
private
|
90
116
|
def validate_evaluation_request(evaluation_request)
|
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.0
|
4
|
+
version: 0.2.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-
|
11
|
+
date: 2024-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Flipt Client Evaluation SDK
|
14
14
|
email:
|
@@ -30,6 +30,7 @@ files:
|
|
30
30
|
- lib/ext/linux_x86_64/libfliptengine.rlib
|
31
31
|
- lib/ext/linux_x86_64/libfliptengine.so
|
32
32
|
- lib/flipt_client.rb
|
33
|
+
- lib/flipt_client/models.rb
|
33
34
|
- lib/flipt_client/version.rb
|
34
35
|
homepage: https://www.flipt.io
|
35
36
|
licenses:
|