class Hoodoo::Client::Endpoint::AutoSession
This endpoint wraps something which does actual communication but requires a session; it maintains a valid session for that wrapped endpoint automatically. It implements the following model:
-
It requires a Caller ID and Caller Authentication Secret to be instantiated (via the
options
parameter). -
If there is no session ID available, it creates one using the above details. Otherwise, it tries to use the given session.
-
If a particular request leads to an ‘invalid session’ response, the request is marked for retry. A new session is obtained first, the retry happens and if it fails this time, the failure is returned to the caller.
Since it wraps another endpoint and requires Caller information to be able to build sessions, instantiation requirements are rather unusual
-
see
configure_with
for details.
Public Instance Methods
See Hoodoo::Client::Endpoint#create
.
# File lib/hoodoo/client/endpoint/endpoints/auto_session.rb, line 94 def create( body_hash, query_hash = nil ) return auto_retry( :create, body_hash, query_hash ) end
See Hoodoo::Client::Endpoint#delete
.
# File lib/hoodoo/client/endpoint/endpoints/auto_session.rb, line 106 def delete( ident, query_hash = nil ) return auto_retry( :delete, ident, query_hash ) end
See Hoodoo::Client::Endpoint#list
.
# File lib/hoodoo/client/endpoint/endpoints/auto_session.rb, line 82 def list( query_hash = nil ) return auto_retry( :list, query_hash ) end
See Hoodoo::Client::Endpoint#show
.
# File lib/hoodoo/client/endpoint/endpoints/auto_session.rb, line 88 def show( ident, query_hash = nil ) return auto_retry( :show, ident, query_hash ) end
See Hoodoo::Client::Endpoint#update
.
# File lib/hoodoo/client/endpoint/endpoints/auto_session.rb, line 100 def update( ident, body_hash, query_hash = nil ) return auto_retry( :update, ident, body_hash, query_hash ) end
Protected Instance Methods
See Hoodoo::Client::Endpoint#configure_with
.
Configuration option keys which must be supplied are:
caller_id
-
The
UUID
of the Caller instance to be used for session creation. caller_secret
-
The authentication secret of the Caller instance to be used for session creation.
- +session_endpoint
-
A Hooodo::Client::Endpoint subclass which can be used for talking to the Session endpoint (for obvious reasons!).
discovery_result
-
A
Hoodoo::Services::Discovery::ForRemote
instance describing the required, remotely available resource endpoint.
The pattern for creating and using this instance is:
-
Discover the location of the remote resource.
-
Use the discovery result to build an appropriate
Endpoint
subclass instance, e.g.Hoodoo::Client::Endpoint::HTTP
. -
Create a
Hoodoo::Services::Discovery::ForRemote
instance which describes the above endpoint via thewrapped_endpoint
option. -
Build an instance of this auto-session
Endpoint
subclass, giving it the above object as thediscovery_result
. -
Use this endpoint in the normal fashion. All the special mechanics of session management are handled here.
# File lib/hoodoo/client/endpoint/endpoints/auto_session.rb, line 71 def configure_with( resource, version, options ) @caller_id = options[ :caller_id ] @caller_secret = options[ :caller_secret ] @session_endpoint = options[ :session_endpoint ] @wrapped_endpoint = @discovery_result.wrapped_endpoint end