eppo-server-sdk 3.1.0 → 3.1.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/Cargo.lock +3 -3
- data/ext/eppo_client/Cargo.toml +3 -2
- data/ext/eppo_client/src/client.rs +33 -32
- data/lib/eppo_client/client.rb +0 -7
- data/lib/eppo_client/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6fb69972c523dd9d2c7c683c751c012608c63bb36fd3a6fe9463fb27d77d3d6
|
4
|
+
data.tar.gz: dfb6b27af63f652094f2141791aaf31be01ce8277801ce6537b30f0cbfa64820
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d191dfefc76fb61a1b873c61da265066e1d674e628864d326d3d51bb3a5c14933fb69aa48e72a1325bd2753a4acc2083bde48d1daf1a408c29b90cea4f858b5
|
7
|
+
data.tar.gz: b79006cc38615b15e44d12362fcc61520ae34f852272fe5a42d4761d7e36e5c407aa1a63df0226109c2198a4798fbb0ded3ce3c0b22fa27e004a69165a2a1696
|
data/Cargo.lock
CHANGED
@@ -304,7 +304,7 @@ dependencies = [
|
|
304
304
|
|
305
305
|
[[package]]
|
306
306
|
name = "eppo_client"
|
307
|
-
version = "3.1.
|
307
|
+
version = "3.1.1"
|
308
308
|
dependencies = [
|
309
309
|
"env_logger",
|
310
310
|
"eppo_core",
|
@@ -317,9 +317,9 @@ dependencies = [
|
|
317
317
|
|
318
318
|
[[package]]
|
319
319
|
name = "eppo_core"
|
320
|
-
version = "
|
320
|
+
version = "3.0.0"
|
321
321
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
322
|
-
checksum = "
|
322
|
+
checksum = "34f3fc5a7f54cc47a5ebf063025176726db7eb5e51661185b5f4d20aaacea611"
|
323
323
|
dependencies = [
|
324
324
|
"chrono",
|
325
325
|
"derive_more",
|
data/ext/eppo_client/Cargo.toml
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
[package]
|
2
2
|
name = "eppo_client"
|
3
|
-
version
|
3
|
+
# TODO: this version and lib/eppo_client/version.rb should be in sync
|
4
|
+
version = "3.1.1"
|
4
5
|
edition = "2021"
|
5
6
|
license = "MIT"
|
6
7
|
publish = false
|
@@ -11,7 +12,7 @@ crate-type = ["cdylib"]
|
|
11
12
|
|
12
13
|
[dependencies]
|
13
14
|
env_logger = { version = "0.11.3", features = ["unstable-kv"] }
|
14
|
-
eppo_core = { version = "
|
15
|
+
eppo_core = { version = "3.0.0" }
|
15
16
|
log = { version = "0.4.21", features = ["kv_serde"] }
|
16
17
|
magnus = { version = "0.6.2" }
|
17
18
|
serde = { version = "1.0.203", features = ["derive"] }
|
@@ -1,12 +1,12 @@
|
|
1
1
|
use std::{cell::RefCell, sync::Arc};
|
2
2
|
|
3
3
|
use eppo_core::{
|
4
|
-
configuration_fetcher::ConfigurationFetcher,
|
4
|
+
configuration_fetcher::{ConfigurationFetcher, ConfigurationFetcherConfig},
|
5
5
|
configuration_store::ConfigurationStore,
|
6
|
-
eval::{
|
6
|
+
eval::{Evaluator, EvaluatorConfig},
|
7
7
|
poller_thread::PollerThread,
|
8
8
|
ufc::VariationType,
|
9
|
-
Attributes, ContextAttributes,
|
9
|
+
Attributes, ContextAttributes, SdkMetadata,
|
10
10
|
};
|
11
11
|
use magnus::{error::Result, exception, prelude::*, Error, TryConvert, Value};
|
12
12
|
|
@@ -28,7 +28,7 @@ impl TryConvert for Config {
|
|
28
28
|
|
29
29
|
#[magnus::wrap(class = "EppoClient::Core::Client")]
|
30
30
|
pub struct Client {
|
31
|
-
|
31
|
+
evaluator: Evaluator,
|
32
32
|
// Magnus only allows sharing aliased references (&T) through the API, so we need to use RefCell
|
33
33
|
// to get interior mutability.
|
34
34
|
//
|
@@ -41,21 +41,28 @@ impl Client {
|
|
41
41
|
pub fn new(config: Config) -> Client {
|
42
42
|
let configuration_store = Arc::new(ConfigurationStore::new());
|
43
43
|
|
44
|
+
let sdk_metadata = SdkMetadata {
|
45
|
+
name: "ruby",
|
46
|
+
version: env!("CARGO_PKG_VERSION"),
|
47
|
+
};
|
48
|
+
|
44
49
|
let poller_thread = PollerThread::start(
|
45
|
-
ConfigurationFetcher::new(
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
sdk_version: env!("CARGO_PKG_VERSION").to_owned(),
|
51
|
-
},
|
52
|
-
),
|
50
|
+
ConfigurationFetcher::new(ConfigurationFetcherConfig {
|
51
|
+
base_url: config.base_url,
|
52
|
+
api_key: config.api_key,
|
53
|
+
sdk_metadata: sdk_metadata.clone(),
|
54
|
+
}),
|
53
55
|
configuration_store.clone(),
|
54
56
|
)
|
55
57
|
.expect("should be able to start poller thread");
|
56
58
|
|
57
|
-
|
59
|
+
let evaluator = Evaluator::new(EvaluatorConfig {
|
58
60
|
configuration_store,
|
61
|
+
sdk_metadata,
|
62
|
+
});
|
63
|
+
|
64
|
+
Client {
|
65
|
+
evaluator,
|
59
66
|
poller_thread: RefCell::new(Some(poller_thread)),
|
60
67
|
}
|
61
68
|
}
|
@@ -70,16 +77,16 @@ impl Client {
|
|
70
77
|
let expected_type: VariationType = serde_magnus::deserialize(expected_type)?;
|
71
78
|
let subject_attributes: Attributes = serde_magnus::deserialize(subject_attributes)?;
|
72
79
|
|
73
|
-
let
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
80
|
+
let result = self
|
81
|
+
.evaluator
|
82
|
+
.get_assignment(
|
83
|
+
&flag_key,
|
84
|
+
&subject_key,
|
85
|
+
&subject_attributes,
|
86
|
+
Some(expected_type),
|
87
|
+
)
|
88
|
+
// TODO: maybe expose possible errors individually.
|
89
|
+
.map_err(|err| Error::new(exception::runtime_error(), err.to_string()))?;
|
83
90
|
|
84
91
|
Ok(serde_magnus::serialize(&result).expect("assignment value should be serializable"))
|
85
92
|
}
|
@@ -94,9 +101,7 @@ impl Client {
|
|
94
101
|
let expected_type: VariationType = serde_magnus::deserialize(expected_type)?;
|
95
102
|
let subject_attributes: Attributes = serde_magnus::deserialize(subject_attributes)?;
|
96
103
|
|
97
|
-
let
|
98
|
-
let result = get_assignment_details(
|
99
|
-
config.as_ref().map(AsRef::as_ref),
|
104
|
+
let result = self.evaluator.get_assignment_details(
|
100
105
|
&flag_key,
|
101
106
|
&subject_key,
|
102
107
|
&subject_attributes,
|
@@ -125,9 +130,7 @@ impl Client {
|
|
125
130
|
})?;
|
126
131
|
let actions = serde_magnus::deserialize(actions)?;
|
127
132
|
|
128
|
-
let
|
129
|
-
let result = get_bandit_action(
|
130
|
-
config.as_ref().map(AsRef::as_ref),
|
133
|
+
let result = self.evaluator.get_bandit_action(
|
131
134
|
&flag_key,
|
132
135
|
&subject_key,
|
133
136
|
&subject_attributes,
|
@@ -157,9 +160,7 @@ impl Client {
|
|
157
160
|
})?;
|
158
161
|
let actions = serde_magnus::deserialize(actions)?;
|
159
162
|
|
160
|
-
let
|
161
|
-
let result = get_bandit_action_details(
|
162
|
-
config.as_ref().map(AsRef::as_ref),
|
163
|
+
let result = self.evaluator.get_bandit_action_details(
|
163
164
|
&flag_key,
|
164
165
|
&subject_key,
|
165
166
|
&subject_attributes,
|
data/lib/eppo_client/client.rb
CHANGED
@@ -144,7 +144,6 @@ module EppoClient
|
|
144
144
|
# events for both flag assignment and bandit actions.
|
145
145
|
event = event.to_h { |key, value| [key.to_sym, value]}
|
146
146
|
|
147
|
-
enrich_event_metadata(event)
|
148
147
|
begin
|
149
148
|
@assignment_logger.log_assignment(event)
|
150
149
|
rescue EppoClient::AssignmentLoggerError
|
@@ -158,7 +157,6 @@ module EppoClient
|
|
158
157
|
def log_bandit_action(event)
|
159
158
|
if not event then return end
|
160
159
|
|
161
|
-
enrich_event_metadata(event)
|
162
160
|
begin
|
163
161
|
@assignment_logger.log_bandit_action(event)
|
164
162
|
rescue EppoClient::AssignmentLoggerError
|
@@ -169,11 +167,6 @@ module EppoClient
|
|
169
167
|
end
|
170
168
|
end
|
171
169
|
|
172
|
-
def enrich_event_metadata(event)
|
173
|
-
event[:metaData]["sdkName"] = "ruby"
|
174
|
-
event[:metaData]["sdkVersion"] = EppoClient::VERSION
|
175
|
-
end
|
176
|
-
|
177
170
|
def coerce_context_attributes(attributes)
|
178
171
|
numeric_attributes = attributes[:numeric_attributes] || attributes["numericAttributes"]
|
179
172
|
categorical_attributes = attributes[:categorical_attributes] || attributes["categoricalAttributes"]
|
data/lib/eppo_client/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eppo-server-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eppo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
64
|
- !ruby/object:Gem::Version
|
65
65
|
version: 3.3.11
|
66
66
|
requirements: []
|
67
|
-
rubygems_version: 3.5.
|
67
|
+
rubygems_version: 3.5.16
|
68
68
|
signing_key:
|
69
69
|
specification_version: 4
|
70
70
|
summary: Eppo SDK for Ruby
|