eppo-server-sdk 3.1.0 → 3.1.2

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: 13377928dbb61c86f0f55c300cce4fd1bbd9298014c34d6e766e6807eec306bb
4
- data.tar.gz: cbaefafb70a5e1267092d7d01a816ffc2520e8cc5b9e21fb22ccd30fc26f6ea0
3
+ metadata.gz: e157a64d8d72757a3bd049d7e40db5589fb7b16d6ff466ea4a1015dbb54fa066
4
+ data.tar.gz: 9a4d5cd6edec77d1b8bf8103debe2b096816b6e9957a1c2308747a5182b5a703
5
5
  SHA512:
6
- metadata.gz: d9edcdd5df7dd9abc465abc275ed46b3e16edc541a5f7eaf5108cc2d21e42a293fbee4d93ad7b0e5db9625397ceb1df0cbdda4558686ee5313cb7c2812b58ca8
7
- data.tar.gz: add2316372855812a3b54c024b171c85a0a87124ff8645ee4bf352897c46b26b2b47627d96726c9b93d4fd8407b3488cf6845de7fe9edae55e0efaf423a44d6f
6
+ metadata.gz: 1b98a6ee8aefd1b833f83ddae8141f42798f825a30f0a54d257f390aa24efc9d8e8a2f1c5b9ff1542db9c11700b7d5fac513c0fa1632aca2f5d22b1eb1a4a9b2
7
+ data.tar.gz: abc686a5a7e46bf85ba655157de3b7ae9b9367e53603d962741d52edac3f42da1e24301a67145b6719663583a89083dbe0e5df757ebf0a6decc8a570f8f64edf
data/Cargo.lock CHANGED
@@ -304,7 +304,7 @@ dependencies = [
304
304
 
305
305
  [[package]]
306
306
  name = "eppo_client"
307
- version = "3.1.0"
307
+ version = "3.1.2"
308
308
  dependencies = [
309
309
  "env_logger",
310
310
  "eppo_core",
@@ -317,12 +317,13 @@ dependencies = [
317
317
 
318
318
  [[package]]
319
319
  name = "eppo_core"
320
- version = "2.0.0"
320
+ version = "4.0.0"
321
321
  source = "registry+https://github.com/rust-lang/crates.io-index"
322
- checksum = "aff693ab3cd82f61d90249aa02c6f7e173202d92727d1036b8fc1468201f9848"
322
+ checksum = "b071fed21065318dcd6a91a443bd9f6b39796d727297b03d092e2e8dc9e02414"
323
323
  dependencies = [
324
324
  "chrono",
325
325
  "derive_more",
326
+ "faststr",
326
327
  "log",
327
328
  "md5",
328
329
  "rand",
@@ -367,6 +368,17 @@ version = "2.1.0"
367
368
  source = "registry+https://github.com/rust-lang/crates.io-index"
368
369
  checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a"
369
370
 
371
+ [[package]]
372
+ name = "faststr"
373
+ version = "0.2.23"
374
+ source = "registry+https://github.com/rust-lang/crates.io-index"
375
+ checksum = "4dc21a7d5a45182c2bb5ae9471b93f10919c0744b54403e54a9e2329c26ed5a3"
376
+ dependencies = [
377
+ "bytes",
378
+ "serde",
379
+ "simdutf8",
380
+ ]
381
+
370
382
  [[package]]
371
383
  name = "fnv"
372
384
  version = "1.0.7"
@@ -1328,6 +1340,12 @@ version = "1.3.0"
1328
1340
  source = "registry+https://github.com/rust-lang/crates.io-index"
1329
1341
  checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
1330
1342
 
1343
+ [[package]]
1344
+ name = "simdutf8"
1345
+ version = "0.1.5"
1346
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1347
+ checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e"
1348
+
1331
1349
  [[package]]
1332
1350
  name = "slab"
1333
1351
  version = "0.4.9"
@@ -1,6 +1,7 @@
1
1
  [package]
2
2
  name = "eppo_client"
3
- version = "3.1.0"
3
+ # TODO: this version and lib/eppo_client/version.rb should be in sync
4
+ version = "3.1.2"
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 = "2.0.0" }
15
+ eppo_core = { version = "4.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::{get_assignment, get_assignment_details, get_bandit_action, get_bandit_action_details},
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
- configuration_store: Arc<ConfigurationStore>,
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
- eppo_core::configuration_fetcher::ConfigurationFetcherConfig {
47
- base_url: config.base_url,
48
- api_key: config.api_key,
49
- sdk_name: "ruby".to_owned(),
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
- Client {
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 config = self.configuration_store.get_configuration();
74
- let result = get_assignment(
75
- config.as_ref().map(AsRef::as_ref),
76
- &flag_key,
77
- &subject_key,
78
- &subject_attributes,
79
- Some(expected_type),
80
- )
81
- // TODO: maybe expose possible errors individually.
82
- .map_err(|err| Error::new(exception::runtime_error(), err.to_string()))?;
80
+ let result = self
81
+ .evaluator
82
+ .get_assignment(
83
+ &flag_key,
84
+ &subject_key.into(),
85
+ &Arc::new(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,12 +101,10 @@ 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 config = self.configuration_store.get_configuration();
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
- &subject_key,
102
- &subject_attributes,
106
+ &subject_key.into(),
107
+ &Arc::new(subject_attributes),
103
108
  Some(expected_type),
104
109
  );
105
110
 
@@ -125,14 +130,12 @@ impl Client {
125
130
  })?;
126
131
  let actions = serde_magnus::deserialize(actions)?;
127
132
 
128
- let config = self.configuration_store.get_configuration();
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
- &subject_key,
135
+ &subject_key.into(),
133
136
  &subject_attributes,
134
137
  &actions,
135
- &default_variation,
138
+ &default_variation.into(),
136
139
  );
137
140
 
138
141
  serde_magnus::serialize(&result)
@@ -157,14 +160,12 @@ impl Client {
157
160
  })?;
158
161
  let actions = serde_magnus::deserialize(actions)?;
159
162
 
160
- let config = self.configuration_store.get_configuration();
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
- &subject_key,
165
+ &subject_key.into(),
165
166
  &subject_attributes,
166
167
  &actions,
167
- &default_variation,
168
+ &default_variation.into(),
168
169
  );
169
170
 
170
171
  serde_magnus::serialize(&result)
@@ -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"]
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # TODO: this version and ext/eppo_rb/Cargo.toml should be in sync
3
+ # TODO: this version and ext/eppo_client/Cargo.toml should be in sync
4
4
  module EppoClient
5
- VERSION = "3.1.0"
5
+ VERSION = "3.1.2"
6
6
  end
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.0
4
+ version: 3.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eppo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-16 00:00:00.000000000 Z
11
+ date: 2024-10-08 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.11
67
+ rubygems_version: 3.5.16
68
68
  signing_key:
69
69
  specification_version: 4
70
70
  summary: Eppo SDK for Ruby