Class: Philotic::Consumer

Inherits:
Subscriber show all
Defined in:
lib/philotic/consumer.rb

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

Constructor Details

This class inherits a constructor from Philotic::Subscriber

Class Method Details

.auto_acknowledgeObject



24
25
26
# File 'lib/philotic/consumer.rb', line 24

def auto_acknowledge
  @auto_acknowledge = true
end

.auto_acknowledge?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/philotic/consumer.rb', line 28

def auto_acknowledge?
  !!@auto_acknowledge
end

.exclusiveObject



32
33
34
# File 'lib/philotic/consumer.rb', line 32

def exclusive
  @exclusive = true
end

.exclusive?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/philotic/consumer.rb', line 36

def exclusive?
  !!@exclusive
end

.manually_acknowledgeObject



16
17
18
# File 'lib/philotic/consumer.rb', line 16

def manually_acknowledge
  @manually_acknowledge = true
end

.manually_acknowledge?Boolean

Returns:

  • (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

.subscribeObject



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

.subscriptionObject



12
13
14
# File 'lib/philotic/consumer.rb', line 12

def subscription
  @subscription
end

.subscription_optionsObject



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

Raises:

  • (NotImplementedError)


72
73
74
# File 'lib/philotic/consumer.rb', line 72

def consume(message)
  raise NotImplementedError
end

#subscribeObject

end class methods



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