Sha256: 17e404635807e8da1e9e3c8461e077b5aeb030bc8e13ae72c7a02bace69f0a06
Contents?: true
Size: 587 Bytes
Versions: 1
Compression:
Stored size: 587 Bytes
Contents
module Grenache class Base def listen(key, port, opts={}, &block) start_http_service(port,&block) announce(key, port, opts) do |res| puts "#{key} announced #{res}" end end def start_http_service(port, &block) EM.defer { app = -> (env) { block.call(env) } server = Thin::Server.start('0.0.0.0', port, app, {signals: false}) } end def request(key, payload, &block) services = lookup(key) json = Oj.dump(payload) res = http.post(services.sample,json).body end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
grenache-ruby-http-0.0.1 | lib/grenache/base.rb |