Class: LaunchDarkly::Impl::Migrations::Executor Private
- Inherits:
-
Object
- Object
- LaunchDarkly::Impl::Migrations::Executor
- Defined in:
- lib/ldclient-rb/impl/migrations/migrator.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Utility class for executing migration operations while also tracking our built-in migration measurements.
Instance Attribute Summary collapse
- #origin ⇒ Symbol readonly private
Instance Method Summary collapse
-
#initialize(logger, origin, fn, tracker, measure_latency, measure_errors, payload) ⇒ Executor
constructor
private
A new instance of Executor.
-
#run ⇒ LaunchDarkly::Migrations::OperationResult
private
Execute the configured operation and track any available measurements.
Constructor Details
#initialize(logger, origin, fn, tracker, measure_latency, measure_errors, payload) ⇒ Executor
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Executor.
257 258 259 260 261 262 263 264 265 |
# File 'lib/ldclient-rb/impl/migrations/migrator.rb', line 257 def initialize(logger, origin, fn, tracker, measure_latency, measure_errors, payload) @logger = logger @origin = origin @fn = fn @tracker = tracker @measure_latency = measure_latency @measure_errors = measure_errors @payload = payload end |
Instance Attribute Details
#origin ⇒ Symbol (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
247 248 249 |
# File 'lib/ldclient-rb/impl/migrations/migrator.rb', line 247 def origin @origin end |
Instance Method Details
#run ⇒ LaunchDarkly::Migrations::OperationResult
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Execute the configured operation and track any available measurements.
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
# File 'lib/ldclient-rb/impl/migrations/migrator.rb', line 272 def run() start = Time.now begin result = @fn.call(@payload) rescue => e Impl::Util.log_exception(@logger, "Unexpected error running method for '#{origin}' origin", e) result = LaunchDarkly::Result.fail("'#{origin}' operation raised an exception", e) end @tracker.latency(@origin, (Time.now - start) * 1_000) if @measure_latency @tracker.error(@origin) if @measure_errors && !result.success? @tracker.invoked(@origin) LaunchDarkly::Migrations::OperationResult.new(@origin, result) end |