Class: Shoryuken::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/shoryuken/client.rb

Overview

Client class for interacting with SQS queues. Provides a simple interface for accessing and managing queue instances.

Constant Summary collapse

@@queues =

Returns cached queue instances by name.

Returns:

{}

Class Method Summary collapse

Class Method Details

.queues(name) ⇒ Shoryuken::Queue

Returns a Queue instance for the given queue name

Parameters:

  • name (String, Symbol)

    the name of the queue

Returns:



15
16
17
# File 'lib/shoryuken/client.rb', line 15

def queues(name)
  @@queues[name.to_s] ||= Shoryuken::Queue.new(sqs, name)
end

.sqsAws::SQS::Client

Returns the current SQS client

Returns:

  • (Aws::SQS::Client)

    the SQS client



22
23
24
# File 'lib/shoryuken/client.rb', line 22

def sqs
  Shoryuken.sqs_client
end

.sqs=(sqs) ⇒ Aws::SQS::Client

Sets a new SQS client and clears the queue cache

Parameters:

  • sqs (Aws::SQS::Client)

    the new SQS client

Returns:

  • (Aws::SQS::Client)

    the SQS client



30
31
32
33
34
35
36
# File 'lib/shoryuken/client.rb', line 30

def sqs=(sqs)
  # Since the @@queues values (Shoryuken::Queue objects) are built referencing @@sqs, if it changes, we need to
  #   re-build them on subsequent calls to `.queues(name)`.
  @@queues = {}

  Shoryuken.sqs_client = sqs
end