Class: Fleck::Core::Consumer

Inherits:
Object
  • Object
show all
Includes:
Actions, Base, Configuration, Decorators, HelpersDefiners, Logger, Loggable
Defined in:
lib/fleck/core/consumer.rb,
lib/fleck/core/consumer/base.rb,
lib/fleck/core/consumer/logger.rb,
lib/fleck/core/consumer/actions.rb,
lib/fleck/core/consumer/request.rb,
lib/fleck/core/consumer/response.rb,
lib/fleck/core/consumer/decorators.rb,
lib/fleck/core/consumer/validation.rb,
lib/fleck/core/consumer/action_param.rb,
lib/fleck/core/consumer/configuration.rb,
lib/fleck/core/consumer/helpers_definers.rb,
lib/fleck/core/consumer/response_helpers.rb

Overview

Open ‘Consumer` class in order to define consumer helpers

Direct Known Subclasses

Fleck::Consumer

Defined Under Namespace

Modules: Actions, Base, Configuration, Decorators, HelpersDefiners, Logger Classes: ActionParam, Request, Response, Validation

Constant Summary

Constants included from HelpersDefiners

HelpersDefiners::INTERRUPT_NAME

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Base

included

Methods included from HelpersDefiners

included

Methods included from Decorators

included

Methods included from Configuration

included

Methods included from Actions

included

Methods included from Logger

included

Methods included from Loggable

#log_error, #logger

Constructor Details

#initialize(consumer_id = nil) ⇒ Consumer

Returns a new instance of Consumer.



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fleck/core/consumer.rb', line 37

def initialize(consumer_id = nil)
  self.consumer_id = consumer_id

  instance_eval(&self.class.initialize_block) if self.class.initialize_block

  start if autostart?

  at_exit do
    terminate
  end
end

Instance Attribute Details

#channelObject

Returns the value of attribute channel.



34
35
36
# File 'lib/fleck/core/consumer.rb', line 34

def channel
  @channel
end

#connectionObject

Returns the value of attribute connection.



34
35
36
# File 'lib/fleck/core/consumer.rb', line 34

def connection
  @connection
end

#consumer_idObject

Returns the value of attribute consumer_id.



34
35
36
# File 'lib/fleck/core/consumer.rb', line 34

def consumer_id
  @consumer_id
end

#consumer_tagObject

Returns the value of attribute consumer_tag.



34
35
36
# File 'lib/fleck/core/consumer.rb', line 34

def consumer_tag
  @consumer_tag
end

#exchangeObject

Returns the value of attribute exchange.



34
35
36
# File 'lib/fleck/core/consumer.rb', line 34

def exchange
  @exchange
end

#publisherObject

Returns the value of attribute publisher.



34
35
36
# File 'lib/fleck/core/consumer.rb', line 34

def publisher
  @publisher
end

#queueObject

Returns the value of attribute queue.



34
35
36
# File 'lib/fleck/core/consumer.rb', line 34

def queue
  @queue
end

#requestObject

Returns the value of attribute request.



34
35
36
# File 'lib/fleck/core/consumer.rb', line 34

def request
  @request
end

#subscriptionObject

Returns the value of attribute subscription.



34
35
36
# File 'lib/fleck/core/consumer.rb', line 34

def subscription
  @subscription
end

Instance Method Details

#deprecated!Object



72
73
74
75
76
# File 'lib/fleck/core/consumer.rb', line 72

def deprecated!
  logger.warn "DEPRECATION: the method `#{caller_locations(1, 1)[0].label}` is going to be deprecated. " \
              'Please, consider using a newer version of this method.'
  response&.deprecated!
end

#headersObject



60
61
62
# File 'lib/fleck/core/consumer.rb', line 60

def headers
  request.headers
end

#paramsObject



64
65
66
# File 'lib/fleck/core/consumer.rb', line 64

def params
  request.params
end

#pauseObject



49
50
51
52
53
54
# File 'lib/fleck/core/consumer.rb', line 49

def pause
  return if subscription.nil? || channel.nil? || channel.closed?

  cancel_ok = subscription.cancel
  self.consumer_tag = cancel_ok.consumer_tag
end

#responseObject



68
69
70
# File 'lib/fleck/core/consumer.rb', line 68

def response
  request.response
end

#resumeObject



56
57
58
# File 'lib/fleck/core/consumer.rb', line 56

def resume
  subscribe!
end