Module: ThreeScale::Backend::StorageAsync::ResqueExtensions

Defined in:
lib/3scale/backend/storage_async/resque_extensions.rb

Instance Method Summary collapse

Instance Method Details

#enqueue(klass, *args) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/3scale/backend/storage_async/resque_extensions.rb', line 9

def enqueue(klass, *args)
  queue = queue_from_class(klass)

  # The redis client is hidden inside a data store that contains a
  # namespace that contains the redis client. Both vars are called
  # "redis".
  async_client = Resque.redis.instance_variable_get(:@redis).instance_variable_get(:@redis)

  # We need to add the "resque" namespace in the keys for all the
  # commands.
  async_client.pipelined do
    async_client.sadd('resque:queues', queue.to_s)
    async_client.rpush(
      "resque:queue:#{queue}", Resque.encode(:class => klass.to_s, :args => args)
    )
  end
end