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

Not compatible with faraday-net_http_persistent #684

Open
brendo opened this issue Sep 20, 2023 · 0 comments
Open

Not compatible with faraday-net_http_persistent #684

brendo opened this issue Sep 20, 2023 · 0 comments

Comments

@brendo
Copy link

brendo commented Sep 20, 2023

We recently attempted to add the faraday-net_http_persistent adapter to our Koala stack and noticed that it wasn't behaving as expected.

After tracing it down, I don't believe Koala is compatible with this adapter because Koala::HTTPService.make_request will create a new Faraday instance for every request:

# set up our Faraday connection
conn = Faraday.new(request.server, faraday_options(request.options), &(faraday_middleware || DEFAULT_MIDDLEWARE))

In doing this, a new connection pool is created each time so there's nothing to share between requests.

I don't believe this is trivial change as the way around it is to create a Faraday connection first (so the middleware stack is built once), and then invokes requests on that connection (a bit similar to the example here). That might be a bit too breaking depending on how folks are using this library 🤔


def get_object(id, args = {}, options = {}, &block)
# Fetches the given object from the graph.
graph_call(id, args, "get", options, &block)
end

koala/lib/koala/api.rb

Lines 46 to 49 in c327913

def graph_call(path, args = {}, verb = "get", options = {}, &post_processing)
# enable appsecret_proof by default
options = {:appsecret_proof => true}.merge(options) if @app_secret
response = api(path, args, verb, options)

koala/lib/koala/api.rb

Lines 121 to 122 in c327913

# make the request via the provided service
result = Koala.make_request(path, args, verb, options)

koala/lib/koala.rb

Lines 60 to 63 in c327913

# An convenenient alias to Koala.http_service.make_request.
def self.make_request(path, args, verb, options = {})
http_service.make_request(HTTPService::Request.new(path: path, args: args, verb: verb, options: options))
end

def self.make_request(request)
# set up our Faraday connection
conn = Faraday.new(request.server, faraday_options(request.options), &(faraday_middleware || DEFAULT_MIDDLEWARE))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant