Class: VCAP::Services::CatalogManagerBase
- Defined in:
- lib/base/catalog_manager_base.rb
Direct Known Subclasses
Instance Method Summary collapse
- #create_http_request(args) {|http, error| ... } ⇒ Object
-
#initialize(opts) ⇒ CatalogManagerBase
constructor
A new instance of CatalogManagerBase.
Constructor Details
#initialize(opts) ⇒ CatalogManagerBase
Returns a new instance of CatalogManagerBase.
7 8 9 |
# File 'lib/base/catalog_manager_base.rb', line 7 def initialize(opts) @proxy_opts = opts[:proxy] end |
Instance Method Details
#create_http_request(args) {|http, error| ... } ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/base/catalog_manager_base.rb', line 11 def create_http_request(args) req = { :head => args[:head], :body => args[:body], } if (@proxy_opts) req[:proxy] = @proxy_opts # this is a workaround for em-http-requesr 0.3.0 so that headers are not lost # more info: https://github.com/igrigorik/em-http-request/issues/130 req[:proxy][:head] = req[:head] end f = Fiber.current http = EM::HttpRequest.new(args[:uri]).send(args[:method], req) if http.error && http.error != "" unless args[:need_raise] @logger.error("CC Catalog Manager: Failed to connect to CC, the error is #{http.error}") return else raise("CC Catalog Manager: Failed to connect to CC, the error is #{http.error}") end end http.callback { f.resume(http, nil) } http.errback { |e| f.resume(http, e) } _, error = Fiber.yield yield http, error if block_given? http end |