rox-rollout 5.0.2 → 5.0.3

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: acfdbd9f2a75d947284c96ac406567af69f9eb61623d079664c0de6b0d26d338
4
- data.tar.gz: db992ff6df1b786b96ba6fdd2625e4037e32e75b272fc7ad8ddf8ef9c170dacf
3
+ metadata.gz: 2d30a63b44e459ce5e10a2b64ce89e3ee59b59ceea67969fda6a1f5b962e43e4
4
+ data.tar.gz: 2bc7318f4e7476830c09fc4c9cf3fbcb9b8e21c0ad6bfdc34ed4e74d321eb8a6
5
5
  SHA512:
6
- metadata.gz: 0aba475fed416f669ba8286b7c1144e04e9171471c1bcf35022a3451d4f6869648a85d80f831f1e363d23a09971d045ada0e3c6579a0aab30169000299f35cba
7
- data.tar.gz: 6366f4efca140a0f5695accd0918ac1ece1d94ba7fea64ff28d45de870f93d7141ba3009eb1379c5986067840e0af1a282a56c6b9274a5b34468a4cd040395d5
6
+ metadata.gz: 2323d41086d92479bdafae351c9aabce8ad99ec4b870b30fb72ada7a8783bf211dbe6380fe80590d79fdd90d077e935d8961dea30436f3211c37cf2a52bb8da6
7
+ data.tar.gz: e3c8ff2bb1018d0d2db497fdbd307a4cac69edee35823f8b35adf47168bfa3339f3ef03401f864f4b918ee83c823e423aa472b44da67ca918f78fcdee02eca53
@@ -8,13 +8,14 @@ jobs:
8
8
  fail-fast: false
9
9
  matrix:
10
10
  os: [ubuntu-latest]
11
- ruby: [2.4, 2.5, 2.6, 2.7, 3.0]
11
+ ruby: [2.4, 2.5, 2.6, 2.7, '3.0', 3.1]
12
12
  runs-on: ${{ matrix.os }}
13
13
  steps:
14
14
  - uses: actions/checkout@v2
15
15
  - uses: ruby/setup-ruby@v1
16
16
  with:
17
17
  ruby-version: ${{ matrix.ruby }}
18
+ bundler: 2.3.3
18
19
  bundler-cache: true # runs 'bundle install' and caches installed gems automatically
19
20
  - run: bundle exec rake test
20
21
  - run: bundle exec rake e2e
@@ -1,4 +1,5 @@
1
1
  require 'rox/core/configuration/configuration_fetched_args'
2
+ require 'rox/core/error_handling/exception_trigger'
2
3
 
3
4
  module Rox
4
5
  module Core
@@ -6,6 +7,7 @@ module Rox
6
7
  def initialize(user_unhandled_error_invoker)
7
8
  @fetched_handlers = []
8
9
  @mutex = Mutex.new
10
+ @internal_handler = nil
9
11
  @user_unhandled_error_invoker = user_unhandled_error_invoker
10
12
  end
11
13
 
@@ -17,6 +19,10 @@ module Rox
17
19
  raise_fetched_event(Rox::Core::ConfigurationFetchedArgs.error(error_details))
18
20
  end
19
21
 
22
+ def register_start_stop_push(block)
23
+ @internal_handler = block
24
+ end
25
+
20
26
  def register_fetched_handler(&block)
21
27
  @mutex.synchronize do
22
28
  @fetched_handlers << block
@@ -24,6 +30,9 @@ module Rox
24
30
  end
25
31
 
26
32
  def raise_fetched_event(args)
33
+ unless @internal_handler.nil?
34
+ @internal_handler.call(args)
35
+ end
27
36
  handlers = []
28
37
  @mutex.synchronize do
29
38
  handlers = @fetched_handlers.clone
@@ -33,7 +42,7 @@ module Rox
33
42
  begin
34
43
  handler.call(args)
35
44
  rescue StandardError => e
36
- user_unhandled_error_invoker.invoke(handler, Rox::Core::CONFIGURATION_FETCHED_HANDLER, e)
45
+ @user_unhandled_error_invoker.invoke(handler, ExceptionTrigger::CONFIGURATION_FETCHED_HANDLER, e)
37
46
  end
38
47
  end
39
48
  end
data/lib/rox/core/core.rb CHANGED
@@ -24,7 +24,6 @@ require 'rox/core/security/signature_verifier'
24
24
  require 'rox/core/security/signature_verifier_mock'
25
25
  require 'rox/core/utils/periodic_task'
26
26
  require 'rox/core/client/dynamic_api'
27
- require 'rox/core/analytics'
28
27
  require 'rox/core/error_handling/userspace_unhandled_error_invoker'
29
28
 
30
29
  module Rox
@@ -72,10 +71,9 @@ module Rox
72
71
  # TODO: Analytics.Analytics.Initialize(deviceProperties.RolloutKey, deviceProperties)
73
72
  @internal_flags = InternalFlags.new(@experiment_repository, @parser, @rox_options)
74
73
 
75
- @analytics_client = Analytics.new(sdk_settings.api_key).client
76
74
  # TODO: impressionInvoker = new ImpressionInvoker(internalFlags, customPropertyRepository, deviceProperties, Analytics.Analytics.Client, roxyPath != null);
77
75
  @impression_invoker = ImpressionInvoker.new(@internal_flags, @custom_property_repository, device_properties,
78
- @analytics_client, !roxy_path.nil?, @user_unhandled_error_invoker)
76
+ nil, !roxy_path.nil?, @user_unhandled_error_invoker)
79
77
  @flag_setter = FlagSetter.new(@flag_repository, @parser, @experiment_repository, @impression_invoker)
80
78
  buid = BUID.new(sdk_settings, device_properties, @flag_repository, @custom_property_repository)
81
79
 
@@ -108,7 +106,11 @@ module Rox
108
106
  configuration_fetched_handler = nil
109
107
  configuration_fetched_handler = @rox_options.configuration_fetched_handler unless @rox_options.nil?
110
108
 
111
- @configuration_fetched_invoker.register_fetched_handler(&wrap_configuration_fetched_handler(&configuration_fetched_handler))
109
+ @configuration_fetched_invoker.register_start_stop_push(proc do |args|
110
+ start_or_stop_push_updated_listener unless args.fetcher_status == FetcherStatus::ERROR_FETCHED_FAILED
111
+ end)
112
+
113
+ @configuration_fetched_invoker.register_fetched_handler(&configuration_fetched_handler)
112
114
 
113
115
  @thread = Thread.new do
114
116
  Thread.current.report_on_exception = false if Thread.current.respond_to?(:report_on_exception)
@@ -136,9 +138,9 @@ module Rox
136
138
  @push_updates_listener = nil
137
139
  end
138
140
 
139
- return if @analytics_client.nil?
141
+ #return if @analytics_client.nil?
140
142
 
141
- @analytics_client.flush
143
+ #@analytics_client.flush
142
144
  end
143
145
 
144
146
  def fetch
@@ -189,13 +191,6 @@ module Rox
189
191
  @custom_property_repository.add_custom_property_if_not_exists(property)
190
192
  end
191
193
 
192
- def wrap_configuration_fetched_handler(&handler)
193
- lambda do |args|
194
- start_or_stop_push_updated_listener unless args.fetcher_status == FetcherStatus::ERROR_FETCHED_FAILED
195
- handler&.call(args)
196
- end
197
- end
198
-
199
194
  def start_or_stop_push_updated_listener
200
195
  if @internal_flags.enabled?('rox.internal.pushUpdates')
201
196
  if @push_updates_listener.nil?
@@ -1,10 +1,11 @@
1
1
  module Rox
2
2
  module Core
3
3
  class UserspaceHandlerException < StandardError
4
- def initialize(exception_source, exception_trigger, exception)
4
+ attr_accessor :exception_source, :exception_trigger, :original_exception
5
+ def initialize(exception_source, exception_trigger, original_exception)
5
6
  @exception_source = exception_source
6
7
  @exception_trigger = exception_trigger
7
- @exception = exception
8
+ @original_exception = original_exception
8
9
  super('user unhandled exception in roxx expression')
9
10
  end
10
11
  end
@@ -18,7 +18,8 @@ module Rox
18
18
  @mutex = Mutex.new
19
19
  end
20
20
 
21
- def invoke(reporting_value, stickiness_property, context)
21
+ # TODO: write analytics client and initiate it before using it
22
+ def call_analytics_gateway(reporting_value, stickiness_property, context)
22
23
  begin
23
24
  analytics_enabled = @internal_flags.enabled?('rox.internal.analytics')
24
25
  if analytics_enabled && !@is_roxy
@@ -47,7 +48,10 @@ module Rox
47
48
  rescue StandardError => ex
48
49
  Logging.logger.error('Failed to send analytics', ex)
49
50
  end
50
-
51
+ end
52
+
53
+ def invoke(reporting_value, stickiness_property, context)
54
+ #call_analytics_gateway
51
55
  raise_impression_event(ImpressionArgs.new(reporting_value, context))
52
56
  end
53
57
 
@@ -63,11 +67,13 @@ module Rox
63
67
  handlers = @impression_handlers.clone
64
68
  end
65
69
 
66
- begin
67
- handlers.each { |handler| handler.call(args) }
68
- rescue StandardError => e
69
- user_unhandled_error_invoker.invoke(handler, ExceptionTrigger::IMPRESSION_HANDLER, e)
70
- Logging.logger.error('Impresssion handler exception', ex)
70
+ handlers.each do |handler|
71
+ begin
72
+ handler.call(args)
73
+ rescue StandardError => e
74
+ @user_unhandled_error_invoker.invoke(handler, ExceptionTrigger::IMPRESSION_HANDLER, e)
75
+ Logging.logger.error('Impresssion handler exception', e)
76
+ end
71
77
  end
72
78
  end
73
79
  end
@@ -1,7 +1,7 @@
1
1
  module Rox
2
2
  module Core
3
3
  class CustomProperty
4
- attr_accessor :name, :type
4
+ attr_accessor :name, :type, :block
5
5
 
6
6
  def initialize(name, type, value = nil, &block)
7
7
  @name = name
@@ -38,13 +38,13 @@ module Rox
38
38
  def get_value_from_dynamic_property_rule_handler(prop_name, context)
39
39
  @dynamic_property_rule_handler.call(prop_name, context)
40
40
  rescue StandardError => e
41
- raise Rox::Core::UserspaceHandlerException, handler, ExceptionTrigger::DYNAMIC_PROPERTIES_RULE, e
41
+ raise Rox::Core::UserspaceHandlerException.new(@dynamic_property_rule_handler, ExceptionTrigger::DYNAMIC_PROPERTIES_RULE, e)
42
42
  end
43
43
 
44
44
  def get_value_from_property(property, context)
45
45
  property.value(context)
46
46
  rescue StandardError => e
47
- raise Rox::Core::UserspaceHandlerException, handler, ExceptionTrigger::CUSTOM_PROPERTY_GENERATOR, e
47
+ raise Rox::Core::UserspaceHandlerException.new(property.block, ExceptionTrigger::CUSTOM_PROPERTY_GENERATOR, e)
48
48
  end
49
49
  end
50
50
  end
@@ -50,7 +50,7 @@ module Rox
50
50
 
51
51
  EvaluationResult.new(result)
52
52
  rescue Rox::Core::UserspaceHandlerException => e
53
- @user_unhandled_error_invoker.invoke(e.exception_source, e.exception_trigger, e.exception)
53
+ @user_unhandled_error_invoker.invoke(e.exception_source, e.exception_trigger, e.original_exception)
54
54
  Logging.logger.warn("Roxx Exception: Failed evaluate expression, user unhandled expression: #{e}")
55
55
  EvaluationResult.new(nil)
56
56
  rescue StandardError => e
data/lib/rox/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rox
2
- VERSION = '5.0.2'.freeze
2
+ VERSION = '5.0.3'.freeze
3
3
  end
data/rox.gemspec CHANGED
@@ -23,10 +23,8 @@ Gem::Specification.new do |spec|
23
23
  spec.required_ruby_version = '>= 2.3'
24
24
 
25
25
  spec.add_runtime_dependency 'em-eventsource', '~> 0.3.2'
26
- spec.add_runtime_dependency 'analytics-ruby', '~> 2.0.0'
27
26
 
28
-
29
- spec.add_development_dependency 'bundler', '~> 2.2.3'
27
+ spec.add_development_dependency 'bundler', '~> 2.3.3'
30
28
  spec.add_development_dependency 'minitest', '~> 5.11'
31
29
  spec.add_development_dependency 'pry-byebug', '~> 3.7.0'
32
30
  spec.add_development_dependency 'rake', '~> 12.3'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rox-rollout
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.2
4
+ version: 5.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - CloudBees
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-10 00:00:00.000000000 Z
11
+ date: 2022-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: em-eventsource
@@ -24,34 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.3.2
27
- - !ruby/object:Gem::Dependency
28
- name: analytics-ruby
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: 2.0.0
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: 2.0.0
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: bundler
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
31
  - - "~>"
46
32
  - !ruby/object:Gem::Version
47
- version: 2.2.3
33
+ version: 2.3.3
48
34
  type: :development
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
38
  - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: 2.2.3
40
+ version: 2.3.3
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: minitest
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -148,7 +134,6 @@ files:
148
134
  - e2e/test_vars.rb
149
135
  - example/local.rb
150
136
  - lib/rox.rb
151
- - lib/rox/core/analytics.rb
152
137
  - lib/rox/core/client/buid.rb
153
138
  - lib/rox/core/client/device_properties.rb
154
139
  - lib/rox/core/client/dynamic_api.rb
@@ -1,18 +0,0 @@
1
- require 'segment/analytics'
2
-
3
- module Rox
4
- module Core
5
- # Analytics based on segment client
6
- # https://segment.com/docs/connections/sources/catalog/libraries/server/ruby/
7
- class Analytics
8
- attr_reader :client
9
-
10
- def initialize(key)
11
- @client = Segment::Analytics.new({
12
- write_key: key,
13
- on_error: proc { |_status, msg| print msg }
14
- })
15
- end
16
- end
17
- end
18
- end