absmartly-sdk 1.3.0.pre.1 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 01cba8157effb3de46d5392c80d36d4247b1a802f0c4ec5fab1758bb2f1059b7
4
- data.tar.gz: dfbe07427f077cd936ec28449f3d42d8efcbb9d09d90b0a171998976acdb442e
3
+ metadata.gz: 2a685c0c9594fccaecbec846d3daae49a0008cac6c000e758565e82f97f1666e
4
+ data.tar.gz: 22758c0fe6ff9f29ed1838eaa86c3182b0690ec79961e94b77df336d881a351d
5
5
  SHA512:
6
- metadata.gz: 5920cdb96b212aa2fbc08d52212b7d15fd11eab5493b50d22d05e51dac2f30414fe2080735ac1f4b1a30c61723c1e41f4841bfc4a623a40686c30d12ef0f4fc0
7
- data.tar.gz: 45cc5a139fd3fdca0c2b97ba98da1ed0caf14b63a70684f3ae983f473016e8147ea269ca7f90f00b5752ddb0f1779c7362d7d706d10079d257f581c1c5914fe3
6
+ metadata.gz: acae59854409db9278c10c2b027dc370a4650b1a70e27516c2ff6a4a421249f5c1df86bd493561718de866a570d4e9da29ec069fd14657560ac6794078dc99c8
7
+ data.tar.gz: 27a309c43c74dfbd388011d78c7079683c0a0d1bc2e62d059748980191104fe7133bf86bd006e09522888a4d00677c37bb79ff6ed2a86d6266f0d906a464569f
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.0.6
1
+ 3.3.10
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ### Added
4
+ - Configurable connection pool settings: `pool_size` and `pool_idle_timeout`
5
+
3
6
  ## [0.1.0] - 2022-08-03
4
7
 
5
8
  - Initial release
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- absmartly-sdk (1.3.0.pre.1)
4
+ absmartly-sdk (1.3.0)
5
5
  base64 (~> 0.2)
6
6
  faraday (~> 2.0)
7
7
  faraday-net_http_persistent (~> 2.0)
@@ -11,12 +11,13 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- ast (2.4.2)
14
+ ast (2.4.3)
15
15
  base64 (0.3.0)
16
16
  byebug (11.1.3)
17
17
  connection_pool (2.5.5)
18
- diff-lcs (1.5.0)
19
- faraday (2.7.4)
18
+ diff-lcs (1.6.2)
19
+ faraday (2.8.1)
20
+ base64
20
21
  faraday-net_http (>= 2.0, < 3.1)
21
22
  ruby2_keywords (>= 0.0.4)
22
23
  faraday-net_http (3.0.2)
@@ -25,50 +26,52 @@ GEM
25
26
  net-http-persistent (>= 4.0.4, < 5)
26
27
  faraday-retry (2.4.0)
27
28
  faraday (~> 2.0)
28
- io-console (0.5.6)
29
- irb (1.2.6)
30
- reline (>= 0.1.5)
31
- json (2.6.2)
29
+ io-console (0.8.2)
30
+ irb (1.6.3)
31
+ reline (>= 0.3.0)
32
+ json (2.7.6)
32
33
  murmurhash3 (0.1.7)
33
34
  net-http-persistent (4.0.8)
34
35
  connection_pool (>= 2.2.4, < 4)
35
- parallel (1.22.1)
36
- parser (3.1.2.0)
36
+ parallel (1.24.0)
37
+ parser (3.3.10.1)
37
38
  ast (~> 2.4.1)
39
+ racc
40
+ racc (1.8.1)
38
41
  rainbow (3.1.1)
39
- rake (13.0.6)
40
- regexp_parser (2.5.0)
41
- reline (0.1.5)
42
+ rake (13.3.1)
43
+ regexp_parser (2.11.3)
44
+ reline (0.6.3)
42
45
  io-console (~> 0.5)
43
46
  rexml (3.4.4)
44
- rspec (3.11.0)
45
- rspec-core (~> 3.11.0)
46
- rspec-expectations (~> 3.11.0)
47
- rspec-mocks (~> 3.11.0)
48
- rspec-core (3.11.0)
49
- rspec-support (~> 3.11.0)
50
- rspec-expectations (3.11.0)
47
+ rspec (3.13.2)
48
+ rspec-core (~> 3.13.0)
49
+ rspec-expectations (~> 3.13.0)
50
+ rspec-mocks (~> 3.13.0)
51
+ rspec-core (3.13.6)
52
+ rspec-support (~> 3.13.0)
53
+ rspec-expectations (3.13.5)
51
54
  diff-lcs (>= 1.2.0, < 2.0)
52
- rspec-support (~> 3.11.0)
53
- rspec-mocks (3.11.1)
55
+ rspec-support (~> 3.13.0)
56
+ rspec-mocks (3.13.7)
54
57
  diff-lcs (>= 1.2.0, < 2.0)
55
- rspec-support (~> 3.11.0)
56
- rspec-support (3.11.0)
57
- rubocop (1.33.0)
58
+ rspec-support (~> 3.13.0)
59
+ rspec-support (3.13.6)
60
+ rubocop (1.50.2)
58
61
  json (~> 2.3)
59
62
  parallel (~> 1.10)
60
- parser (>= 3.1.0.0)
63
+ parser (>= 3.2.0.0)
61
64
  rainbow (>= 2.2.2, < 4.0)
62
65
  regexp_parser (>= 1.8, < 3.0)
63
66
  rexml (>= 3.2.5, < 4.0)
64
- rubocop-ast (>= 1.19.1, < 2.0)
67
+ rubocop-ast (>= 1.28.0, < 2.0)
65
68
  ruby-progressbar (~> 1.7)
66
- unicode-display_width (>= 1.4.0, < 3.0)
67
- rubocop-ast (1.19.1)
68
- parser (>= 3.1.1.0)
69
- ruby-progressbar (1.11.0)
69
+ unicode-display_width (>= 2.4.0, < 3.0)
70
+ rubocop-ast (1.30.0)
71
+ parser (>= 3.2.1.0)
72
+ ruby-progressbar (1.13.0)
70
73
  ruby2_keywords (0.0.5)
71
- unicode-display_width (2.2.0)
74
+ unicode-display_width (2.6.0)
72
75
 
73
76
  PLATFORMS
74
77
  ruby
data/README.md CHANGED
@@ -33,6 +33,8 @@ Absmartly.configure_client do |config|
33
33
  config.connection_request_timeout = 3.0
34
34
  config.retry_interval = 0.5
35
35
  config.max_retries = 5
36
+ config.pool_size = 20
37
+ config.pool_idle_timeout = 5
36
38
  end
37
39
  ```
38
40
 
@@ -48,6 +50,8 @@ end
48
50
  | connection_request_timeout | `number` | &#10060; | `3.0` | The request timeout in seconds. |
49
51
  | retry_interval | `number` | &#10060; | `0.5` | The initial retry interval in seconds (uses exponential backoff). |
50
52
  | max_retries | `number` | &#10060; | `5` | The maximum number of retries before giving up. |
53
+ | pool_size | `number` | &#10060; | `20` | The number of connections in the HTTP connection pool. |
54
+ | pool_idle_timeout | `number` | &#10060; | `5` | The time in seconds before idle connections are closed. |
51
55
  | event_logger | `ContextEventLogger` | &#10060; | See "Using a Custom Event Logger" below | A `ContextEventLogger` instance implementing `handle_event(event, data)` to receive SDK events. |
52
56
 
53
57
  ### Using a Custom Event Logger
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Absmartly
4
- VERSION = "1.3.0.pre.1"
4
+ VERSION = "1.3.0"
5
5
  end
data/lib/context.rb CHANGED
@@ -43,6 +43,7 @@ class Context
43
43
  @hashed_units = {}
44
44
  @pending_count = 0
45
45
  @exposures ||= []
46
+ @attrs_seq = 0
46
47
 
47
48
  set_units(config.units) if config.units
48
49
  set_attributes(config.attributes) if config.attributes
@@ -137,6 +138,7 @@ class Context
137
138
  check_not_closed?
138
139
 
139
140
  @attributes.push(Attribute.new(name, value, @clock.to_i))
141
+ @attrs_seq += 1
140
142
  end
141
143
 
142
144
  def set_attributes(attributes)
@@ -184,6 +186,8 @@ class Context
184
186
  assignment(experiment_name).variant
185
187
  end
186
188
 
189
+ alias peek peek_treatment
190
+
187
191
  def variable_keys
188
192
  check_ready?(true)
189
193
 
@@ -375,6 +379,26 @@ class Context
375
379
  experiment.traffic_split == assignment.traffic_split
376
380
  end
377
381
 
382
+ def audience_matches(experiment, assignment)
383
+ if !experiment.audience.nil? && experiment.audience.size > 0
384
+ if @attrs_seq > (assignment.attrs_seq || 0)
385
+ attrs = @attributes.inject({}) do |hash, attr|
386
+ hash[attr.name] = attr.value
387
+ hash
388
+ end
389
+ match = @audience_matcher.evaluate(experiment.audience, attrs)
390
+ new_audience_mismatch = match && !match.result
391
+
392
+ if new_audience_mismatch != assignment.audience_mismatch
393
+ return false
394
+ end
395
+
396
+ assignment.attrs_seq = @attrs_seq
397
+ end
398
+ end
399
+ true
400
+ end
401
+
378
402
  def assignment(experiment_name)
379
403
  assignment = @assignment_cache[experiment_name.to_s]
380
404
 
@@ -391,7 +415,9 @@ class Context
391
415
  return assignment
392
416
  end
393
417
  elsif custom.nil? || custom == assignment.variant
394
- return assignment if experiment_matches(experiment.data, assignment)
418
+ if experiment_matches(experiment.data, assignment) && audience_matches(experiment.data, assignment)
419
+ return assignment
420
+ end
395
421
  end
396
422
  end
397
423
 
@@ -461,10 +487,11 @@ class Context
461
487
  assignment.iteration = experiment.data.iteration
462
488
  assignment.traffic_split = experiment.data.traffic_split
463
489
  assignment.full_on_variant = experiment.data.full_on_variant
490
+ assignment.attrs_seq = @attrs_seq
464
491
  end
465
492
  end
466
493
 
467
- if !experiment.nil? && assignment.variant < experiment.data.variants.length
494
+ if !experiment.nil? && assignment.variant >= 0 && assignment.variant < experiment.data.variants.length
468
495
  assignment.variables = experiment.variables[assignment.variant] || {}
469
496
  end
470
497
 
@@ -529,7 +556,7 @@ class Context
529
556
  value.value = @variable_parser.parse(self, experiment.name, custom_field_value.name, custom_value)
530
557
 
531
558
  elsif custom_field_value.type.start_with?("boolean")
532
- value.value = custom_value.to_bool
559
+ value.value = custom_value == "true"
533
560
 
534
561
  elsif custom_field_value.type.start_with?("number")
535
562
  value.value = custom_value.to_i
@@ -603,7 +630,7 @@ end
603
630
  class Assignment
604
631
  attr_accessor :id, :iteration, :full_on_variant, :name, :unit_type,
605
632
  :traffic_split, :variant, :assigned, :overridden, :eligible,
606
- :full_on, :custom, :audience_mismatch, :variables, :exposed
633
+ :full_on, :custom, :audience_mismatch, :variables, :exposed, :attrs_seq
607
634
 
608
635
  def initialize
609
636
  @variant = 0
@@ -616,6 +643,7 @@ class Assignment
616
643
  @full_on = false
617
644
  @custom = false
618
645
  @audience_mismatch = false
646
+ @attrs_seq = 0
619
647
  end
620
648
  end
621
649
 
@@ -23,8 +23,8 @@ class DefaultHttpClient < HttpClient
23
23
  backoff_factor: 2
24
24
  f.options.timeout = config.connect_timeout
25
25
  f.options.open_timeout = config.connection_request_timeout
26
- f.adapter :net_http_persistent, pool_size: 20 do |http|
27
- http.idle_timeout = 5
26
+ f.adapter :net_http_persistent, pool_size: config.pool_size do |http|
27
+ http.idle_timeout = config.pool_idle_timeout
28
28
  end
29
29
  end
30
30
  end
@@ -4,7 +4,9 @@ class DefaultHttpClientConfig
4
4
  attr_accessor :connect_timeout,
5
5
  :connection_request_timeout,
6
6
  :retry_interval,
7
- :max_retries
7
+ :max_retries,
8
+ :pool_size,
9
+ :pool_idle_timeout
8
10
 
9
11
  def self.create
10
12
  DefaultHttpClientConfig.new
@@ -15,5 +17,7 @@ class DefaultHttpClientConfig
15
17
  @connection_request_timeout = 3.0
16
18
  @retry_interval = 0.5
17
19
  @max_retries = 5
20
+ @pool_size = 20
21
+ @pool_idle_timeout = 5
18
22
  end
19
23
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: absmartly-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0.pre.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - absmartly
8
+ autorequire:
8
9
  bindir: exe
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2026-01-26 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: base64
@@ -168,6 +169,7 @@ metadata:
168
169
  homepage_uri: https://github.com/absmartly/ruby-sdk
169
170
  source_code_uri: https://github.com/absmartly/ruby-sdk
170
171
  changelog_uri: https://github.com/absmartly/ruby-sdk
172
+ post_install_message:
171
173
  rdoc_options: []
172
174
  require_paths:
173
175
  - lib
@@ -182,7 +184,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
184
  - !ruby/object:Gem::Version
183
185
  version: '0'
184
186
  requirements: []
185
- rubygems_version: 3.7.1
187
+ rubygems_version: 3.5.22
188
+ signing_key:
186
189
  specification_version: 4
187
190
  summary: Absmartly gem
188
191
  test_files: []