Class: Philotic::Consumer
Instance Attribute Summary
Attributes inherited from Subscriber
#connection
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Subscriber
#acknowledge, #config, #endure, #get_subscription_settings, #initialize, #initialize_queue, #logger, #reject, #subscribe_to_any, #subscription_callback
Class Method Details
.auto_acknowledge ⇒ Object
24
25
26
|
# File 'lib/philotic/consumer.rb', line 24
def auto_acknowledge
@auto_acknowledge = true
end
|
.auto_acknowledge? ⇒ Boolean
28
29
30
|
# File 'lib/philotic/consumer.rb', line 28
def auto_acknowledge?
!!@auto_acknowledge
end
|
.exclusive ⇒ Object
32
33
34
|
# File 'lib/philotic/consumer.rb', line 32
def exclusive
@exclusive = true
end
|
.exclusive? ⇒ Boolean
36
37
38
|
# File 'lib/philotic/consumer.rb', line 36
def exclusive?
!!@exclusive
end
|
.manually_acknowledge ⇒ Object
16
17
18
|
# File 'lib/philotic/consumer.rb', line 16
def manually_acknowledge
@manually_acknowledge = true
end
|
.manually_acknowledge? ⇒ Boolean
20
21
22
|
# File 'lib/philotic/consumer.rb', line 20
def manually_acknowledge?
!!@manually_acknowledge
end
|
.rejectable_errors(*errors) ⇒ Object
46
47
48
49
50
|
# File 'lib/philotic/consumer.rb', line 46
def rejectable_errors(*errors)
@rejectable_errors ||= Set.new
@rejectable_errors.merge errors
@rejectable_errors
end
|
.requeueable_errors(*errors) ⇒ Object
40
41
42
43
44
|
# File 'lib/philotic/consumer.rb', line 40
def requeueable_errors(*errors)
@requeueable_errors ||= Set.new
@requeueable_errors.merge errors
@requeueable_errors
end
|
.subscribe ⇒ Object
52
53
54
55
56
|
# File 'lib/philotic/consumer.rb', line 52
def subscribe
new(Philotic.connection).tap do |instance|
instance.subscribe
end
end
|
.subscribe_to(subscription) ⇒ Object
8
9
10
|
# File 'lib/philotic/consumer.rb', line 8
def subscribe_to(subscription)
@subscription = subscription
end
|
.subscription ⇒ Object
12
13
14
|
# File 'lib/philotic/consumer.rb', line 12
def subscription
@subscription
end
|
.subscription_options ⇒ Object
58
59
60
61
62
63
|
# File 'lib/philotic/consumer.rb', line 58
def subscription_options
{
manual_ack: auto_acknowledge? || manually_acknowledge?,
exclusive: exclusive?,
}
end
|
Instance Method Details
#consume(message) ⇒ Object
72
73
74
|
# File 'lib/philotic/consumer.rb', line 72
def consume(message)
raise NotImplementedError
end
|
#subscribe ⇒ Object
66
67
68
69
70
|
# File 'lib/philotic/consumer.rb', line 66
def subscribe
super(self.class.subscription, self.class.subscription_options) do |message|
_consume(message)
end
end
|