Class: Eventboss::Queue

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/eventboss/queue.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Queue

Returns a new instance of Queue.



30
31
32
33
# File 'lib/eventboss/queue.rb', line 30

def initialize(name)
  @client = Eventboss.configuration.sqs_client
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/eventboss/queue.rb', line 6

def name
  @name
end

Class Method Details

.build(destination:, event_name:, env:, source_app: nil) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/eventboss/queue.rb', line 19

def build(destination:, event_name:, env:, source_app: nil)
  name = build_name(
    destination: destination,
    event_name: event_name,
    env: env,
    source_app: source_app
  )
  Queue.new(name)
end

.build_name(destination:, event_name:, env:, source_app: nil) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/eventboss/queue.rb', line 9

def build_name(destination:, event_name:, env:, source_app: nil)
  [
    destination,
    Eventboss.configuration.sns_sqs_name_infix,
    source_app,
    event_name,
    env
  ].compact.join('-')
end

Instance Method Details

#<=>(another_queue) ⇒ Object



48
49
50
# File 'lib/eventboss/queue.rb', line 48

def <=>(another_queue)
  name <=> another_queue&.name
end

#arnObject



39
40
41
42
43
44
45
46
# File 'lib/eventboss/queue.rb', line 39

def arn
  [
    'arn:aws:sqs',
    Eventboss.configuration.eventboss_region,
    Eventboss.configuration.,
    name
  ].join(':')
end

#eql?(another_queue) ⇒ Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/eventboss/queue.rb', line 52

def eql?(another_queue)
  name == another_queue&.name
end

#hashObject



56
57
58
# File 'lib/eventboss/queue.rb', line 56

def hash
  name.hash
end

#to_sObject



60
61
62
# File 'lib/eventboss/queue.rb', line 60

def to_s
  "<Eventboss::Queue: #{name}>"
end

#urlObject



35
36
37
# File 'lib/eventboss/queue.rb', line 35

def url
  @url ||= client.get_queue_url(queue_name: name).queue_url
end