Class: Mingle::EmHttpMingleRpcClient

Inherits:
BitGirder::Core::BitGirderClass show all
Defined in:
lib/mingle-em.rb

Constant Summary collapse

HTTP_PRE_POST =
:http_pre_post
HTTP_RESP_RECEIVED =
:http_resp_received
MG_RESP_CREATED =
:mg_resp_created
@@codec =
JsonMingleCodec.new

Constants included from BitGirder::Core::BitGirderMethods

BitGirder::Core::BitGirderMethods::PARAM_TYPE_ARG, BitGirder::Core::BitGirderMethods::PARAM_TYPE_ENVVAR, BitGirder::Core::BitGirderMethods::PARAM_TYPE_KEY

Instance Method Summary collapse

Methods included from BitGirder::Core::BitGirderMethods

argv_to_argh, check_fail_prefix, class_name_to_sym, code, compares_to, console, ext_to_class_name, ext_to_sym, has_env, has_key, has_keys, nonnegative, not_nil, positive, raisef, set_from_key, set_var, split_argv, sym_to_cli_switch, sym_to_ext_id, to_bool, unpack_argv_array, unpack_argv_hash, warn

Methods included from BitGirder::Core::BitGirderStructure

#==, included

Instance Method Details

#begin(mg_req, &blk) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/mingle-em.rb', line 59

def begin( mg_req, &blk )
    
    not_nil( mg_req, "mg_req" )
    raise "Need a response handler block" unless blk

    req = EM::HttpRequest.new( @endpoint )

    post_args = { :body => @@codec.as_codec_object( mg_req ) }
    cli_log( HTTP_PRE_POST, post_args )

    http = req.post( post_args )

    http.callback do |resp| 

        cli_log( HTTP_RESP_RECEIVED, resp )
        handle_response( resp, blk )
    end
end

#call(ns, svc, op, params = nil, auth = nil, &blk) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/mingle-em.rb', line 78

def call( ns, svc, op, params = nil, auth = nil, &blk )
    
    req =
        MingleServiceRequest.new(
            :namespace => ns,
            :service => svc,
            :operation => op,
            :parameters => params,
            :authentication => auth )

    self.begin( req, &blk )
end