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.

Methods
C
D
L
M
S
U
Attributes
[RW] alchemy

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.

Instance Public methods
create( body_hash, query_hash = nil )
# 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 )
# 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 )
# 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 )

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:

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.

# 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 )
# 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 )
# 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
Instance Protected methods
configure_with( resource, version, options )

See Hoodoo::Client::Endpoint#configure_with.

Requires a Hoodoo::Services::Discovery::ForAMQP instance in the discovery_result field of the options Hash.

# File lib/hoodoo/client/endpoint/endpoints/amqp.rb, line 33
def configure_with( resource, version, options )
  unless @discovery_result.is_a?( Hoodoo::Services::Discovery::ForAMQP )
    raise "Hoodoo::Client::Endpoint::AMQP must be configured with a Hoodoo::Services::Discovery::ForAMQP instance - got '#{ @discovery_result.class.name }'"
  end

  # Host and port isn't relevant for Alchemy but *is* needed
  # to keep Rack happy.

  endpoint_uri      = URI.parse( 'http://localhost:80' )
  endpoint_uri.path = @discovery_result.routing_path

  @description                  = Hoodoo::Client::Endpoint::HTTPBased::DescriptionOfRequest.new
  @description.discovery_result = @discovery_result
  @description.endpoint_uri     = endpoint_uri
end