Sha256: c0be0b359039ac882bbda79aac73a0a0f1a23f5e0be9c76100480c9a45353ff3

Contents?: true

Size: 741 Bytes

Versions: 57

Compression:

Stored size: 741 Bytes

Contents

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

57 entries across 57 versions & 1 rubygems

Version Path
sidekiq-4.1.1 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-4.1.0 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-3.5.4 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-4.0.2 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-4.0.1 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-4.0.0 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-4.0.0.pre2 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-3.5.3 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-4.0.0.pre1 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-3.5.2 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-3.5.1 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-3.5.0 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-3.4.2 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-3.4.1 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-3.4.0 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-3.3.4 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-3.3.3 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-3.3.2 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-3.3.1 lib/sidekiq/extensions/generic_proxy.rb
sidekiq-3.3.0 lib/sidekiq/extensions/generic_proxy.rb