lib/grenache/http.rb in grenache-ruby-http-0.1.2 vs lib/grenache/http.rb in grenache-ruby-http-0.1.3

- old
+ new

@@ -10,23 +10,24 @@ end def start_http_service(port, &block) EM.defer { app = -> (env) { - block.call(env) + resp = block.call(env) + [200,nil, Message.req(resp).to_json] } server = Thin::Server.start('0.0.0.0', port, app, {signals: false}) } end - def request(key, payload, &block) + def request(key, payload) services = lookup(key) if services.size > 0 - json = Oj.dump(payload) + json = Message.req(payload).to_json service = services.sample.sub("tcp://","http://") service.prepend("http://") unless service.start_with?("http://") resp = HTTParty.post(service,{body: json}) - return [nil, Oj.load(resp.body)] + return [false, Message.parse(resp.body)] else return ["NoPeerFound",nil] end rescue Exception => e return [e, nil]