Module: DistribCore::DRbHelper

Defined in:
lib/distrib_core/drb_helper.rb

Overview

Helper that handles some problematic cases with DRb.

Class Method Summary collapse

Class Method Details

.drb_unknown?(*objects) ⇒ TrueClass, FalseClass

Checks if any of the passed object is a ‘DRbUnknown`. It tries to load such objects and logs explained error if fails. Used on Leader when receiving report from workers.

Parameters:

  • objects (Array<Object>)

Returns:

  • (TrueClass, FalseClass)

    ‘true` if failed to load one of the passed objects



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/distrib_core/drb_helper.rb', line 13

def drb_unknown?(*objects)
  got_drb_unknown = false

  objects.each do |object|
    next unless object.is_a?(DRb::DRbUnknown)

    error = error_of_marshal_load(object)

    logger.error 'Parse error:'
    logger.error error
    logger.debug "Can't parse: #{object.inspect}"

    got_drb_unknown = true
  end

  got_drb_unknown
end

.dump_failed?(error, objects) ⇒ TrueClass, FalseClass

Checks if error was caused by ‘Marshal#dump`. Recursively explores object and tries to `Marshal.dump` it. If dump failed - calls the same function for its instance variables. Logs path to the un-dumpable object. Used on Worker to find objects(or parts) which can’t be sent to Leader.

Parameters:

  • error (Exception)
  • objects (Object)

Returns:

  • (TrueClass, FalseClass)


40
41
42
43
44
45
# File 'lib/distrib_core/drb_helper.rb', line 40

def dump_failed?(error, objects)
  return false unless marshal_error?(error)

  dig_dump(objects)
  true
end