Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused em-http-request #4069

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ gem 'allowy', '>= 2.1.0'
gem 'clockwork', require: false
gem 'cloudfront-signer'
gem 'digest-xxhash'
gem 'em-http-request', '~> 1.1'
gem 'eventmachine', '~> 1.2.7'
gem 'fluent-logger'
gem 'googleapis-common-protos', '>= 1.3.12'
Expand Down
11 changes: 0 additions & 11 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ GEM
coderay (1.1.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
cookiejar (0.3.3)
crack (1.0.0)
bigdecimal
rexml
Expand All @@ -148,14 +147,6 @@ GEM
domain_name (0.6.20240107)
drb (2.2.1)
e2mmap (0.1.0)
em-http-request (1.1.7)
addressable (>= 2.3.4)
cookiejar (!= 0.3.1)
em-socksify (>= 0.3)
eventmachine (>= 1.0.3)
http_parser.rb (>= 0.6.0)
em-socksify (0.3.2)
eventmachine (>= 1.0.0.beta.4)
erubi (1.13.0)
eventmachine (1.2.7)
excon (0.112.0)
Expand Down Expand Up @@ -275,7 +266,6 @@ GEM
http-cookie (1.0.5)
domain_name (~> 0.5)
http-form_data (2.3.0)
http_parser.rb (0.6.0)
httpclient (2.8.3)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
Expand Down Expand Up @@ -609,7 +599,6 @@ DEPENDENCIES
codeclimate-test-reporter (>= 1.0.8)
debug (~> 1.9)
digest-xxhash
em-http-request (~> 1.1)
eventmachine (~> 1.2.7)
fluent-logger
fog-aliyun
Expand Down
60 changes: 0 additions & 60 deletions lib/vcap/services/api/async_requests.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Copyright (c) 2009-2011 VMware, Inc.
require 'eventmachine'
require 'em-http-request'
require 'httpclient'

require 'vcap/services/api/const'
Expand All @@ -13,38 +11,6 @@ module Api
end

module VCAP::Services::Api
class AsyncHttpRequest
class << self
def new(url, token, verb, timeout, msg=VCAP::Services::Api::EMPTY_REQUEST)
req = {
head: {
VCAP::Services::Api::GATEWAY_TOKEN_HEADER => token,
'Content-Type' => 'application/json'
},
body: msg.encode
}
if timeout
EM::HttpRequest.new(url, inactivity_timeout: timeout).send(verb.to_sym, req)
else
EM::HttpRequest.new(url).send(verb.to_sym, req)
end
end

def request(url, token, verb, timeout, msg=VCAP::Services::Api::EMPTY_REQUEST)
req = new(url, token, verb, timeout, msg)
f = Fiber.current
req.callback { f.resume(req) }
req.errback { f.resume(req) }
http = Fiber.yield
raise UnexpectedResponse.new("Error sending request #{msg.extract.to_json} to gateway #{@url}: #{http.error}") unless http.error.empty?

code = http.response_header.status.to_i
body = http.response
[code, body]
end
end
end

module SynchronousHttpRequest
Copy link
Contributor

@Samze Samze Nov 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question/non-blocking I see SynchronousHttpRequest is used https://github.com/cloudfoundry/cloud_controller_ng/blob/main/app/models/services/managed_service_instance.rb#L99 but is requester method called elsewhere? Quick grep would suggest maybe not.

rg requester
src/code.cloudfoundry.org/cc-uploader/handlers/upload_build_artifacts/upload_build_artifacts_test.go
131:		Context("when the requester (client) goes away", func() {

src/code.cloudfoundry.org/cc-uploader/handlers/upload_droplet/upload_droplet_test.go
178:		Context("when the requester (client) goes away", func() {

src/cloud_controller_ng/app/models/services/managed_service_instance.rb
98:    def requester

src/github.com/cloudfoundry/blobstore_url_signer/server/handler_test.go
49:			It("writes the signed URL back to requester", func() {
74:			It("writes the signed URL back to requester", func() {

Also, it seems like all of the lib/vcap/services/api stuff is from the very old v1 service broker contract, is that even used anywhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't think about it too hard at the time because with this PR I was trying to unblock the Ruby 3.3 upgrade, but I think you're right. I made another PR that removes the other old services code to keep the priority/purpose of this PR distinct: #4085

def self.request(url, token, verb, _timeout, msg=VCAP::Services::Api::EMPTY_REQUEST)
header = {
Expand All @@ -57,30 +23,4 @@ def self.request(url, token, verb, _timeout, msg=VCAP::Services::Api::EMPTY_REQU
[msg.code, msg.body]
end
end

class AsyncHttpMultiPartUpload
class << self
def new(url, timeout, multipart, head={})
req = {
head: head,
body: '',
multipart: multipart
}

if timeout
EM::HttpRequest.new(url, inactivity_timeout: timeout).post req
else
EM::HttpRequest.new(url).post req
end
end

def fibered(url, timeout, multipart, head={})
req = new(url, timeout, multipart, head)
f = Fiber.current
req.callback { f.resume(req) }
req.errback { f.resume(req) }
Fiber.yield
end
end
end
end