flipt_client 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -1
- data/lib/ext/darwin_arm64/libfliptengine.d +1 -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.d +1 -1
- data/lib/ext/linux_arm64/libfliptengine.rlib +0 -0
- data/lib/ext/linux_arm64/libfliptengine.so +0 -0
- data/lib/ext/linux_x86_64/libfliptengine.d +1 -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/models.rb +39 -0
- data/lib/flipt_client/version.rb +1 -1
- data/lib/flipt_client.rb +28 -0
- 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: 1cbfce772261a0e968cbcc2b0135b851e86dda4107abe8cac583a2c2cb23692c
|
4
|
+
data.tar.gz: ae3cad47961fabefe5abd90310a3f91a3e57d35dbd976e98b0a82939bfd988b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edb56a32998775cc00ff7cbc54302978e40a1f0eae8f16b15684a872d3f713b73652e924391556d6a2683a2483059a8421cb98603bc724723dc9d095813deb61
|
7
|
+
data.tar.gz: 7d684bead44f7d8eae6091f46dfcfe1bcdb8d391cdaad9796f398ab96b902e71d7a04e87678d66c5fc7df215796620a069be770d764c05e1d2f6234ca911a16f
|
data/README.md
CHANGED
@@ -10,6 +10,17 @@ The `flipt-client-ruby` directory contains the Ruby source code for the Flipt [c
|
|
10
10
|
gem install flipt_client
|
11
11
|
```
|
12
12
|
|
13
|
+
## Using System Libffi
|
14
|
+
|
15
|
+
If you are experiencing segfaults when using this gem, you may need to configure `ffi` to use the system libffi instead of the bundled one.
|
16
|
+
|
17
|
+
You can do this before installing the gem by running the following command:
|
18
|
+
|
19
|
+
```bash
|
20
|
+
gem install ffi -- --enable-system-libffi # to install the gem manually
|
21
|
+
bundle config build.ffi --enable-system-libffi # for bundle install
|
22
|
+
```
|
23
|
+
|
13
24
|
## Usage
|
14
25
|
|
15
26
|
In your Ruby code you can import this client and use it as so:
|
@@ -22,7 +33,9 @@ require 'flipt_client'
|
|
22
33
|
# {
|
23
34
|
# "url": "http://localhost:8080",
|
24
35
|
# "update_interval": 120,
|
25
|
-
# "
|
36
|
+
# "authentication": {
|
37
|
+
# "client_token": "secret"
|
38
|
+
# }
|
26
39
|
# }
|
27
40
|
#
|
28
41
|
# You can replace the url with where your upstream Flipt instance points to, the update interval for how long you are willing
|
@@ -1 +1 @@
|
|
1
|
-
/Users/runner/work/flipt-client-sdks/flipt-client-sdks/target/aarch64-apple-darwin/release/libfliptengine.rlib: /Users/runner/work/flipt-client-sdks/flipt-client-sdks/flipt-engine/build.rs /Users/runner/work/flipt-client-sdks/flipt-client-sdks/flipt-engine/
|
1
|
+
/Users/runner/work/flipt-client-sdks/flipt-client-sdks/target/aarch64-apple-darwin/release/libfliptengine.rlib: /Users/runner/work/flipt-client-sdks/flipt-client-sdks/flipt-engine-ffi/build.rs /Users/runner/work/flipt-client-sdks/flipt-client-sdks/flipt-engine-ffi/src/lib.rs /Users/runner/work/flipt-client-sdks/flipt-client-sdks/flipt-evaluation/src/error/mod.rs /Users/runner/work/flipt-client-sdks/flipt-client-sdks/flipt-evaluation/src/lib.rs /Users/runner/work/flipt-client-sdks/flipt-client-sdks/flipt-evaluation/src/models/common.rs /Users/runner/work/flipt-client-sdks/flipt-client-sdks/flipt-evaluation/src/models/flipt.rs /Users/runner/work/flipt-client-sdks/flipt-client-sdks/flipt-evaluation/src/models/mod.rs /Users/runner/work/flipt-client-sdks/flipt-client-sdks/flipt-evaluation/src/models/source.rs /Users/runner/work/flipt-client-sdks/flipt-client-sdks/flipt-evaluation/src/parser/mod.rs /Users/runner/work/flipt-client-sdks/flipt-client-sdks/flipt-evaluation/src/store/mod.rs
|
Binary file
|
Binary file
|
@@ -1 +1 @@
|
|
1
|
-
/target/aarch64-unknown-linux-gnu/release/libfliptengine.rlib: /project/flipt-engine/build.rs /project/flipt-engine/lib/evaluation/src/error/mod.rs /project/flipt-
|
1
|
+
/target/aarch64-unknown-linux-gnu/release/libfliptengine.rlib: /project/flipt-engine-ffi/build.rs /project/flipt-engine-ffi/src/lib.rs /project/flipt-evaluation/src/error/mod.rs /project/flipt-evaluation/src/lib.rs /project/flipt-evaluation/src/models/common.rs /project/flipt-evaluation/src/models/flipt.rs /project/flipt-evaluation/src/models/mod.rs /project/flipt-evaluation/src/models/source.rs /project/flipt-evaluation/src/parser/mod.rs /project/flipt-evaluation/src/store/mod.rs
|
Binary file
|
Binary file
|
@@ -1 +1 @@
|
|
1
|
-
/home/runner/work/flipt-client-sdks/flipt-client-sdks/target/x86_64-unknown-linux-gnu/release/libfliptengine.rlib: /home/runner/work/flipt-client-sdks/flipt-client-sdks/flipt-engine/build.rs /home/runner/work/flipt-client-sdks/flipt-client-sdks/flipt-engine/
|
1
|
+
/home/runner/work/flipt-client-sdks/flipt-client-sdks/target/x86_64-unknown-linux-gnu/release/libfliptengine.rlib: /home/runner/work/flipt-client-sdks/flipt-client-sdks/flipt-engine-ffi/build.rs /home/runner/work/flipt-client-sdks/flipt-client-sdks/flipt-engine-ffi/src/lib.rs /home/runner/work/flipt-client-sdks/flipt-client-sdks/flipt-evaluation/src/error/mod.rs /home/runner/work/flipt-client-sdks/flipt-client-sdks/flipt-evaluation/src/lib.rs /home/runner/work/flipt-client-sdks/flipt-client-sdks/flipt-evaluation/src/models/common.rs /home/runner/work/flipt-client-sdks/flipt-client-sdks/flipt-evaluation/src/models/flipt.rs /home/runner/work/flipt-client-sdks/flipt-client-sdks/flipt-evaluation/src/models/mod.rs /home/runner/work/flipt-client-sdks/flipt-client-sdks/flipt-evaluation/src/models/source.rs /home/runner/work/flipt-client-sdks/flipt-client-sdks/flipt-evaluation/src/parser/mod.rs /home/runner/work/flipt-client-sdks/flipt-client-sdks/flipt-evaluation/src/store/mod.rs
|
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
|
|
@@ -36,8 +37,23 @@ module Flipt
|
|
36
37
|
# const char *evaluate_boolean(void *engine_ptr, const char *evaluation_request);
|
37
38
|
attach_function :evaluate_boolean, %i[pointer string], :string
|
38
39
|
|
40
|
+
# Create a new Flipt client
|
41
|
+
#
|
42
|
+
# @param namespace [String] namespace
|
43
|
+
# @param opts [Hash] options
|
44
|
+
# @option opts [String] :url Flipt server url
|
45
|
+
# @option opts [AuthenticationStrategy] :authentication strategy to authenticate with Flipt
|
46
|
+
# @option opts [Integer] :update_interval interval in seconds to update the cache
|
47
|
+
# @option opts [String] :reference reference to use for namespace data
|
39
48
|
def initialize(namespace = 'default', opts = {})
|
40
49
|
@namespace = namespace
|
50
|
+
|
51
|
+
# set default no auth if not provided
|
52
|
+
authentication = opts.fetch(:authentication, Flipt::NoAuthentication.new)
|
53
|
+
raise ArgumentError, "invalid authentication strategy" unless authentication && authentication.is_a?(Flipt::AuthenticationStrategy)
|
54
|
+
|
55
|
+
opts[:authentication] = authentication.strategy
|
56
|
+
|
41
57
|
namespace_list = [namespace]
|
42
58
|
ns = FFI::MemoryPointer.new(:pointer, namespace_list.size)
|
43
59
|
namespace_list.each_with_index do |namespace, i|
|
@@ -52,6 +68,12 @@ module Flipt
|
|
52
68
|
proc { destroy_engine(engine) }
|
53
69
|
end
|
54
70
|
|
71
|
+
# Evaluate a variant flag for a given request
|
72
|
+
#
|
73
|
+
# @param evaluation_request [Hash] evaluation request
|
74
|
+
# @option evaluation_request [String] :entity_id entity id
|
75
|
+
# @option evaluation_request [String] :flag_key flag key
|
76
|
+
# @option evaluation_request [String] :namespace_key override namespace key
|
55
77
|
def evaluate_variant(evaluation_request = {})
|
56
78
|
evaluation_request[:namespace_key] = @namespace
|
57
79
|
validate_evaluation_request(evaluation_request)
|
@@ -59,6 +81,12 @@ module Flipt
|
|
59
81
|
JSON.parse(resp)
|
60
82
|
end
|
61
83
|
|
84
|
+
# Evaluate a boolean flag for a given request
|
85
|
+
#
|
86
|
+
# @param evaluation_request [Hash] evaluation request
|
87
|
+
# @option evaluation_request [String] :entity_id entity id
|
88
|
+
# @option evaluation_request [String] :flag_key flag key
|
89
|
+
# @option evaluation_request [String] :namespace_key override namespace key
|
62
90
|
def evaluate_boolean(evaluation_request = {})
|
63
91
|
evaluation_request[:namespace_key] = @namespace
|
64
92
|
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.1.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-01-
|
11
|
+
date: 2024-01-25 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:
|