eppo-server-sdk 3.2.8 → 3.3.0

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: 79b744c41c8a742d2df4fde1a15526cf8038c6964f6f40c002ad5db40bc07ec9
4
- data.tar.gz: 66935bbbd726aae639df57ded1ea85c3fd0a486c400ed1449422689724479a34
3
+ metadata.gz: 48c186c8f79fbdb739eca53ecc09b128864046a6c510502ab2932f9ac1835205
4
+ data.tar.gz: '09175d83959067a77f5a5260d5e20b70b95e7e2cdd2f7d97ed0220a40b2be2db'
5
5
  SHA512:
6
- metadata.gz: 6100d75714febc77b512967d0f801a6c6474ee41d8dab148818f8e90a5c194afed96d34f926d56da9be79ae4ab548a60af25de6efb26920d15ef6353c04cd9ca
7
- data.tar.gz: 6819df24b91952da523daf34dfe216532dfaabe20cdc4a4341aec40ec3083642cdd24a425090f3804f43d2de7be4a7d935523f0f3597acca6da3e32736522fad
6
+ metadata.gz: ece6f38eeb759216f8c0b25b37f9fc4e520e187073a5ac84c34af5c2d46b18050cea639a7dbbdd494bf7d7e32bcd5376977df6abf30a7205ff6b79c657656b46
7
+ data.tar.gz: 3791032b0cdc69ffd44f3d63dc7558c19c8370e576196edefefcaefbe60586a0417cbb8e30b348c7b4af34c64bd88d2a8bd0414c6ce8cf90a838a2026c64fd93
data/Cargo.lock CHANGED
@@ -304,7 +304,7 @@ dependencies = [
304
304
 
305
305
  [[package]]
306
306
  name = "eppo_client"
307
- version = "3.2.8"
307
+ version = "3.3.0"
308
308
  dependencies = [
309
309
  "env_logger",
310
310
  "eppo_core",
@@ -318,9 +318,9 @@ dependencies = [
318
318
 
319
319
  [[package]]
320
320
  name = "eppo_core"
321
- version = "4.1.0"
321
+ version = "4.1.1"
322
322
  source = "registry+https://github.com/rust-lang/crates.io-index"
323
- checksum = "626df025f5b474b42ead14953310e31e81e4b88ce52a993573bf87bc9def12d4"
323
+ checksum = "f847d078c379d2102582e483751dd1a4444fd3e1863e6f23e852fc99c52270e6"
324
324
  dependencies = [
325
325
  "chrono",
326
326
  "derive_more",
@@ -334,6 +334,7 @@ dependencies = [
334
334
  "serde",
335
335
  "serde_json",
336
336
  "thiserror",
337
+ "tokio",
337
338
  "url",
338
339
  ]
339
340
 
@@ -417,7 +418,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
417
418
  checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78"
418
419
  dependencies = [
419
420
  "futures-core",
420
- "futures-sink",
421
421
  ]
422
422
 
423
423
  [[package]]
@@ -426,12 +426,6 @@ version = "0.3.30"
426
426
  source = "registry+https://github.com/rust-lang/crates.io-index"
427
427
  checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d"
428
428
 
429
- [[package]]
430
- name = "futures-io"
431
- version = "0.3.30"
432
- source = "registry+https://github.com/rust-lang/crates.io-index"
433
- checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1"
434
-
435
429
  [[package]]
436
430
  name = "futures-sink"
437
431
  version = "0.3.30"
@@ -451,13 +445,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
451
445
  checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48"
452
446
  dependencies = [
453
447
  "futures-core",
454
- "futures-io",
455
- "futures-sink",
456
448
  "futures-task",
457
- "memchr",
458
449
  "pin-project-lite",
459
450
  "pin-utils",
460
- "slab",
461
451
  ]
462
452
 
463
453
  [[package]]
@@ -1098,7 +1088,6 @@ dependencies = [
1098
1088
  "base64",
1099
1089
  "bytes",
1100
1090
  "encoding_rs",
1101
- "futures-channel",
1102
1091
  "futures-core",
1103
1092
  "futures-util",
1104
1093
  "h2",
data/README.md CHANGED
@@ -7,6 +7,23 @@ Refer to our [SDK documentation](https://docs.geteppo.com/feature-flags/sdks/rub
7
7
  ## Supported Ruby Versions
8
8
  This version of the SDK is compatible with Ruby 3.0.6 and above.
9
9
 
10
+ ## Logging
11
+
12
+ Ruby SDK uses [`env_logger`](https://docs.rs/env_logger/) for logging.
13
+
14
+ Starting from version 3.3.0, the log level can be configured via `EPPO_LOG` environment variable using one of the following values:
15
+ - `off`
16
+ - `error`
17
+ - `warn`
18
+ - `info` (default)
19
+ - `debug`
20
+ - `trace`
21
+
22
+ Alternatively, it can be configured using `log_level` parameter for `EppoClient::Config` constructor:
23
+ ```ruby
24
+ config = EppoClient::Config.new("sdk-key", log_level: "debug")
25
+ ```
26
+
10
27
  # Contributing
11
28
 
12
29
  ## Testing with local version of `eppo_core`
@@ -1,7 +1,7 @@
1
1
  [package]
2
2
  name = "eppo_client"
3
3
  # TODO: this version and lib/eppo_client/version.rb should be in sync
4
- version = "3.2.8"
4
+ version = "3.3.0"
5
5
  edition = "2021"
6
6
  license = "MIT"
7
7
  publish = false
@@ -12,7 +12,7 @@ crate-type = ["cdylib"]
12
12
 
13
13
  [dependencies]
14
14
  env_logger = { version = "0.11.3", features = ["unstable-kv"] }
15
- eppo_core = { version = "4.1.0", features = ["vendored"] }
15
+ eppo_core = { version = "4.1.1", features = ["vendored"] }
16
16
  log = { version = "0.4.21", features = ["kv_serde"] }
17
17
  magnus = { version = "0.6.4" }
18
18
  serde = { version = "1.0.203", features = ["derive"] }
@@ -1,4 +1,4 @@
1
- use std::{cell::RefCell, sync::Arc, time::Duration};
1
+ use std::{cell::RefCell, str::FromStr, sync::Arc, time::Duration};
2
2
 
3
3
  use eppo_core::{
4
4
  configuration_fetcher::{ConfigurationFetcher, ConfigurationFetcherConfig},
@@ -19,6 +19,7 @@ pub struct Config {
19
19
  base_url: String,
20
20
  poll_interval: Option<Duration>,
21
21
  poll_jitter: Duration,
22
+ log_level: Option<log::LevelFilter>,
22
23
  }
23
24
 
24
25
  impl TryConvert for Config {
@@ -29,11 +30,22 @@ impl TryConvert for Config {
29
30
  let poll_interval_seconds =
30
31
  Option::<u64>::try_convert(val.funcall("poll_interval_seconds", ())?)?;
31
32
  let poll_jitter_seconds = u64::try_convert(val.funcall("poll_jitter_seconds", ())?)?;
33
+
34
+ let log_level = {
35
+ let s = Option::<String>::try_convert(val.funcall("log_level", ())?)?;
36
+ s.map(|s| {
37
+ log::LevelFilter::from_str(&s)
38
+ .map_err(|err| Error::new(exception::runtime_error(), err.to_string()))
39
+ })
40
+ .transpose()?
41
+ };
42
+
32
43
  Ok(Config {
33
44
  api_key,
34
45
  base_url,
35
46
  poll_interval: poll_interval_seconds.map(Duration::from_secs),
36
47
  poll_jitter: Duration::from_secs(poll_jitter_seconds),
48
+ log_level,
37
49
  })
38
50
  }
39
51
  }
@@ -52,6 +64,23 @@ pub struct Client {
52
64
 
53
65
  impl Client {
54
66
  pub fn new(config: Config) -> Client {
67
+ // Initialize logger
68
+ {
69
+ let mut builder = env_logger::Builder::from_env(
70
+ env_logger::Env::new()
71
+ .filter_or("EPPO_LOG", "eppo=info")
72
+ .write_style("EPPO_LOG_STYLE"),
73
+ );
74
+
75
+ if let Some(log_level) = config.log_level {
76
+ builder.filter_module("eppo", log_level);
77
+ }
78
+
79
+ // Logger can only be set once, so we ignore the initialization error here if client is
80
+ // re-initialized.
81
+ let _ = builder.try_init();
82
+ };
83
+
55
84
  let configuration_store = Arc::new(ConfigurationStore::new());
56
85
 
57
86
  let poller_thread = if let Some(poll_interval) = config.poll_interval {
@@ -14,8 +14,6 @@ pub(crate) const SDK_METADATA: SdkMetadata = SdkMetadata {
14
14
 
15
15
  #[magnus::init]
16
16
  fn init(ruby: &Ruby) -> Result<(), Error> {
17
- env_logger::Builder::from_env(env_logger::Env::new().default_filter_or("eppo=debug")).init();
18
-
19
17
  let eppo_client = ruby.define_module("EppoClient")?;
20
18
  let core = eppo_client.define_module("Core")?;
21
19
 
@@ -6,14 +6,15 @@ require_relative "assignment_logger"
6
6
  module EppoClient
7
7
  # The class for configuring the Eppo client singleton
8
8
  class Config
9
- attr_reader :api_key, :assignment_logger, :base_url, :poll_interval_seconds, :poll_jitter_seconds
9
+ attr_reader :api_key, :assignment_logger, :base_url, :poll_interval_seconds, :poll_jitter_seconds, :log_level
10
10
 
11
- def initialize(api_key, assignment_logger: AssignmentLogger.new, base_url: EppoClient::Core::DEFAULT_BASE_URL, poll_interval_seconds: EppoClient::Core::DEFAULT_POLL_INTERVAL_SECONDS, poll_jitter_seconds: EppoClient::Core::DEFAULT_POLL_JITTER_SECONDS, initial_configuration: nil)
11
+ def initialize(api_key, assignment_logger: AssignmentLogger.new, base_url: EppoClient::Core::DEFAULT_BASE_URL, poll_interval_seconds: EppoClient::Core::DEFAULT_POLL_INTERVAL_SECONDS, poll_jitter_seconds: EppoClient::Core::DEFAULT_POLL_JITTER_SECONDS, initial_configuration: nil, log_level: nil)
12
12
  @api_key = api_key
13
13
  @assignment_logger = assignment_logger
14
14
  @base_url = base_url
15
15
  @poll_interval_seconds = poll_interval_seconds
16
16
  @poll_jitter_seconds = poll_jitter_seconds
17
+ @log_level = log_level
17
18
  end
18
19
 
19
20
  def validate
@@ -2,5 +2,5 @@
2
2
 
3
3
  # TODO: this version and ext/eppo_client/Cargo.toml should be in sync
4
4
  module EppoClient
5
- VERSION = "3.2.8"
5
+ VERSION = "3.3.0"
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.2.8
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eppo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-10-31 00:00:00.000000000 Z
11
+ date: 2024-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rb_sys
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  - !ruby/object:Gem::Version
74
74
  version: 3.3.11
75
75
  requirements: []
76
- rubygems_version: 3.5.16
76
+ rubygems_version: 3.5.22
77
77
  signing_key:
78
78
  specification_version: 4
79
79
  summary: Eppo SDK for Ruby