Sha256: 6d9a5b78115e075f4b5c7b69e991da831e95f2a026d63ba558d951a3939cd1d6

Contents?: true

Size: 771 Bytes

Versions: 15

Compression:

Stored size: 771 Bytes

Contents

# frozen_string_literal: true
require 'yaml'

module Sidekiq
  module Extensions
    class Proxy < BasicObject
      def initialize(performable, target, options={})
        @performable = performable
        @target = target
        @opts = options
      end

      def method_missing(name, *args)
        # Sidekiq has a limitation in that its message must be JSON.
        # JSON can't round trip real Ruby objects so we use YAML to
        # serialize the objects to a String.  The YAML will be converted
        # to JSON and then deserialized on the other side back into a
        # Ruby object.
        obj = [@target, name, args]
        @performable.client_push({ 'class' => @performable, 'args' => [::YAML.dump(obj)] }.merge(@opts))
      end
    end

  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
sidekiq-4.2.10 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-4.2.9 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-4.2.8 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-4.2.7 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-4.2.6 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-4.2.5 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-4.2.4 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-4.2.3 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-4.2.2 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-4.2.1 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-4.2.0 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-4.1.4 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-4.1.3 lib/sidekiq/extensions/generic_proxy.rb
sr-sidekiq-4.1.6 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-4.1.2 lib/sidekiq/extensions/generic_proxy.rb