Class: Hoodoo::Client::Endpoint::AMQP

Inherits:
HTTPBased show all
Defined in:
lib/hoodoo/client/endpoint/endpoints/amqp.rb

Overview

Talk to a resource that is contacted over AMQP using HTTP emulation via the Alchemy and AMQ Endpoint gems.

Calls cannot be made until #alchemy= has been called to set an Alchemy caller instance. The Alchemy http_request method is called on this instance to perform the over-queue HTTP simulation.

Configured with a Hoodoo::Services::Discovery::ForAMQP discovery result instance.

Instance Attribute Summary collapse

Attributes inherited from Hoodoo::Client::Endpoint

#interaction, #locale, #resource, #session_id, #version

Instance Method Summary collapse

Methods inherited from Hoodoo::Client::Endpoint

endpoint_for, #initialize

Constructor Details

This class inherits a constructor from Hoodoo::Client::Endpoint

Instance Attribute Details

#alchemyObject

Set/get the Alchemy caller instance. Its http_request method is called to perform the over-queue HTTP simulation.

Instances of the AMQP endpoint can be created, but cannot be used for resource calls - #list, #show, #create, #update and #delete cannot be called - until an Alchemy instance has been specified. An exception will be raised if you try.



59
60
61
# File 'lib/hoodoo/client/endpoint/endpoints/amqp.rb', line 59

def alchemy
  @alchemy
end

Instance Method Details

#create(body_hash, query_hash = nil) ⇒ Object

See Hoodoo::Client::Endpoint#create.



84
85
86
87
88
89
90
91
# File 'lib/hoodoo/client/endpoint/endpoints/amqp.rb', line 84

def create( body_hash, query_hash = nil )
  d            = @description.dup
  d.action     = :create
  d.body_hash  = body_hash
  d.query_hash = query_hash

  return do_amqp( d )
end

#delete(ident, query_hash = nil) ⇒ Object

See Hoodoo::Client::Endpoint#delete.



107
108
109
110
111
112
113
114
# File 'lib/hoodoo/client/endpoint/endpoints/amqp.rb', line 107

def delete( ident, query_hash = nil )
  d            = @description.dup
  d.action     = :delete
  d.ident      = ident
  d.query_hash = query_hash

  return do_amqp( d )
end

#list(query_hash = nil) ⇒ Object

See Hoodoo::Client::Endpoint#list.



63
64
65
66
67
68
69
# File 'lib/hoodoo/client/endpoint/endpoints/amqp.rb', line 63

def list( query_hash = nil )
  d            = @description.dup # This does NOT dup the objects to which @description points
  d.action     = :list
  d.query_hash = query_hash

  return do_amqp( d )
end

#monkey_send_request(http_message, full_uri) ⇒ Object

Ask Alchemy Flux to send a given HTTP message to a resource.

This method is available for Hoodoo monkey patching but must not be called by third party code; it’s a private method exposed in the public monkey_ namespace for patching only. For more, see:

  • Hoodoo::Monkey

  • Hoodoo::Monkey::Patch::NewRelicTracedAMQP

  • Hoodoo::Monkey::Patch::DatadogTracedAMQP

http_message

Hash describing the message to send.

full_uri

Equivalent full URI of the request (information only; the http_message tells Alchemy Flux how to route the message; it does not consult this parameter).

The return value is an Alchemy Flux response object.



135
136
137
# File 'lib/hoodoo/client/endpoint/endpoints/amqp.rb', line 135

def monkey_send_request( http_message, full_uri )
  self.alchemy().send_request_to_resource( http_message )
end

#show(ident, query_hash = nil) ⇒ Object

See Hoodoo::Client::Endpoint#show.



73
74
75
76
77
78
79
80
# File 'lib/hoodoo/client/endpoint/endpoints/amqp.rb', line 73

def show( ident, query_hash = nil )
  d            = @description.dup
  d.action     = :show
  d.ident      = ident
  d.query_hash = query_hash

  return do_amqp( d )
end

#update(ident, body_hash, query_hash = nil) ⇒ Object

See Hoodoo::Client::Endpoint#update.



95
96
97
98
99
100
101
102
103
# File 'lib/hoodoo/client/endpoint/endpoints/amqp.rb', line 95

def update( ident, body_hash, query_hash = nil )
  d            = @description.dup
  d.action     = :update
  d.ident      = ident
  d.body_hash  = body_hash
  d.query_hash = query_hash

  return do_amqp( d )
end