Class: LaunchDarkly::Impl::Migrations::Executor Private

Inherits:
Object
  • Object
show all
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.

Since:

  • 5.5.0

Instance Attribute Summary collapse

Instance Method Summary collapse

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.

Parameters:

Since:

  • 5.5.0



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

#originSymbol (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.

Returns:

  • (Symbol)

Since:

  • 5.5.0



247
248
249
# File 'lib/ldclient-rb/impl/migrations/migrator.rb', line 247

def origin
  @origin
end

Instance Method Details

#runLaunchDarkly::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