Class: Appfuel::MsgRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/appfuel/msg_request.rb

Overview

This represents the message delivered by RabbitMQ. We encapsulate it so that if you want to fire an action from the command line you can use a CliRequest and not worry about rabbit details

Direct Known Subclasses

CliMsgRequest

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(msg, delivery_info, metadata) ⇒ Object

metadata properties

headers:        message headers, important for service_route
reply_to:       name of rpc response queue
correlation_id: id used in rpc to match response

Parameters:

  • msg

    String serialized message from rabbitmq

  • delivery_info

    Hash info used to acknowledge messages

  • metadata

    Object properties of the messages



21
22
23
24
25
26
# File 'lib/appfuel/msg_request.rb', line 21

def initialize(msg, delivery_info, )
  @auditable         =  true
  self.inputs        = msg
  self.delivery_info = delivery_info
  self.properties    = 
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



7
8
9
# File 'lib/appfuel/msg_request.rb', line 7

def action
  @action
end

#configObject (readonly)

Returns the value of attribute config.



7
8
9
# File 'lib/appfuel/msg_request.rb', line 7

def config
  @config
end

#correlation_idObject (readonly)

Returns the value of attribute correlation_id.



7
8
9
# File 'lib/appfuel/msg_request.rb', line 7

def correlation_id
  @correlation_id
end

#current_userObject

Returns the value of attribute current_user.



7
8
9
# File 'lib/appfuel/msg_request.rb', line 7

def current_user
  @current_user
end

#delivery_infoObject

Returns the value of attribute delivery_info.



7
8
9
# File 'lib/appfuel/msg_request.rb', line 7

def delivery_info
  @delivery_info
end

#featureObject (readonly)

Returns the value of attribute feature.



7
8
9
# File 'lib/appfuel/msg_request.rb', line 7

def feature
  @feature
end

#inputsObject

Returns the value of attribute inputs.



7
8
9
# File 'lib/appfuel/msg_request.rb', line 7

def inputs
  @inputs
end

#propertiesObject

Returns the value of attribute properties.



7
8
9
# File 'lib/appfuel/msg_request.rb', line 7

def properties
  @properties
end

#reply_toObject (readonly)

Returns the value of attribute reply_to.



7
8
9
# File 'lib/appfuel/msg_request.rb', line 7

def reply_to
  @reply_to
end

#service_routeObject

Returns the value of attribute service_route.



7
8
9
# File 'lib/appfuel/msg_request.rb', line 7

def service_route
  @service_route
end

Instance Method Details

#auditable?Boolean

Flag used to determine if the request should be sent to the audit log. The default value is true and a header is used to opt out of this.

Returns:

  • (Boolean)


41
42
43
# File 'lib/appfuel/msg_request.rb', line 41

def auditable?
  @auditable
end

#current_user?Boolean

The current user is required for all audit logs and this flag is used to determine if it exists. When an audit is not required the current user is optional

Returns:

  • (Boolean)


50
51
52
# File 'lib/appfuel/msg_request.rb', line 50

def current_user?
  !@current_user.nil?
end

#rpc?Boolean

Rpc requires a reply queue to respond to and a correlation_id to identify that response in the queue. When these two things exist then the request is consided to be an rpc

Returns:

  • (Boolean)


33
34
35
# File 'lib/appfuel/msg_request.rb', line 33

def rpc?
  !reply_to.nil? && !correlation_id.nil?
end