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

Http driver config #273

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open

Http driver config #273

wants to merge 19 commits into from

Conversation

brucek
Copy link
Contributor

@brucek brucek commented Nov 18, 2016

Fixes #272

This pull introduces/changes:

  • adds an :http_adaptor option to CypherSession::Adaptors::HTTP.new for Faraday adaptor

Pings:
@cheerfulstoic
@subvertallchris

@coveralls
Copy link

coveralls commented Nov 18, 2016

Coverage Status

Coverage increased (+0.3%) to 92.626% when pulling b011c46 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 92.626% when pulling b011c46 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 92.626% when pulling b011c46 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

coveralls commented Nov 18, 2016

Coverage Status

Coverage increased (+0.3%) to 92.626% when pulling 662fed4 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 92.626% when pulling 662fed4 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

coveralls commented Nov 18, 2016

Coverage Status

Coverage increased (+0.3%) to 92.626% when pulling f270f53 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

3 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 92.626% when pulling f270f53 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 92.626% when pulling f270f53 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 92.626% when pulling f270f53 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

coveralls commented Nov 18, 2016

Coverage Status

Coverage increased (+0.02%) to 92.382% when pulling 7dbcf0a on brucek:http_driver_config into 7abe23c on neo4jrb:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 92.382% when pulling 7dbcf0a on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 92.382% when pulling 7dbcf0a on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

coveralls commented Nov 18, 2016

Coverage Status

Coverage decreased (-8.7%) to 83.677% when pulling f9c2f31 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

4 similar comments
@coveralls
Copy link

Coverage Status

Coverage decreased (-8.7%) to 83.677% when pulling f9c2f31 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-8.7%) to 83.677% when pulling f9c2f31 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-8.7%) to 83.677% when pulling f9c2f31 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-8.7%) to 83.677% when pulling f9c2f31 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

coveralls commented Nov 18, 2016

Coverage Status

Coverage increased (+0.02%) to 92.382% when pulling f376dc9 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

coveralls commented Nov 18, 2016

Coverage Status

Coverage increased (+0.04%) to 92.398% when pulling eee66cc on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 92.425% when pulling aea75e0 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

6 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 92.425% when pulling aea75e0 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 92.425% when pulling aea75e0 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 92.425% when pulling aea75e0 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 92.425% when pulling aea75e0 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 92.425% when pulling aea75e0 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 92.425% when pulling aea75e0 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

coveralls commented Dec 2, 2016

Coverage Status

Coverage increased (+0.06%) to 92.425% when pulling e6e1844 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 92.425% when pulling bb32ab4 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

8 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 92.425% when pulling bb32ab4 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 92.425% when pulling bb32ab4 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 92.425% when pulling bb32ab4 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 92.425% when pulling bb32ab4 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 92.425% when pulling bb32ab4 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 92.425% when pulling bb32ab4 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 92.425% when pulling bb32ab4 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 92.425% when pulling bb32ab4 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

coveralls commented Dec 2, 2016

Coverage Status

Coverage increased (+0.02%) to 92.383% when pulling bb32ab4 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

Copy link
Contributor

@cheerfulstoic cheerfulstoic left a comment

Choose a reason for hiding this comment

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

I feel like I'm not following the conversation very well because of all of the noise from coveralls, so sorry if I'm repeating things unnecessarily.... I also feel like I haven't been engaging well enough in this PR until now because of time restrictions, so please forgive me if things are a bit confusing.

But one general point: If you don't care about the old session code, I don't either. I'm perfectly happy to only implement this change in the new HTTP adaptor which would simplify things

@@ -16,7 +17,8 @@ def initialize(url, options = {})
end

def connect
@requestor = Requestor.new(@url, USER_AGENT_STRING, self.class.method(:instrument_request))
@requestor = Requestor.new(@url, USER_AGENT_STRING, self.class.method(:instrument_request),
@options[:faraday_options] || @options['faraday_options'] || {})
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that you should just be able to do @options['faraday_options'] || {}, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not unless I stringify_keys! since coders will likely use :faraday_options but when config'ed via neo4j.yml (ie in Rails), the keys are strings. There is an explicit test for this.

c.response :multi_json, symbolize_keys: true, content_type: 'application/json'
c.use Faraday::Adapter::NetHttpPersistent

conn = Faraday.new(url) do |c|
# c.response :logger, ::Logger.new(STDOUT), bodies: true
Copy link
Contributor

Choose a reason for hiding this comment

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

Just verifying, if you leave these lines in, are they no longer defaults but rather they override the options?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is my understanding - all the middleware that gets called during initialization gets mounted in Faraday and these would then always get mounted no matter if people wanted them or not, and there would be no way to get rid of them.

end

def extract_basic_auth(url, params)
return unless url && URI(url).userinfo
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a huge deal, but you could perhaps create a uri object at the start and use it in all of the places you're using URI(url)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call

def verify_faraday_options(faraday_options = {}, defaults = {})
faraday_options.symbolize_keys!.reverse_merge!(defaults)
faraday_options[:adapter] ||= :net_http_persistent
require 'typhoeus/adapters/faraday' if faraday_options[:adapter].to_sym == :typhoeus
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the user require the gem paths that they need depending on the adaptor that they are using? That way we wouldn't need to include the various gems in our Gemfile

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that is true... I was just bitten by typhoeus/typhoeus#226 (comment) which was a little hard to track down the solution, so I figured it would be a little easier to just handle that for them instead (plus it is only needed here, not in their project generally). Happy to take it out if you'd rather doc it / force folks to figure it out, but it seems like an easy win that doesn't really cost much here.

in the Gemfile I only include the adapter gems in :test (and not in the .gemspec) so tests here will fail if there's any issues vs letting people hit them when using whatever gems and fail and then report issues.

I can imagine if there is any issues with the adapter gem(s), it requires a little work to maintain the tests, but again, it seems like an easy thing we can stay on top of here vs just letting people get bitten and have to figure it out themselves..?

I'm of the understanding that only the .gemspec gems are exposed outwards, and so having gem in the Gemfile doesn't really impact anyone else - is that correct?

faraday.send key, value
end
end
end
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not really sure I get why all of this is necessary. Doesn't the second argument of Faraday.new take a hash of options which is an alternative to sending methods to the faraday object in the block syntax? Maybe that's where we're misunderstanding...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't look too hard, but I took these comments to mean no since I don't see anything mentioning :response as a key, for instance. But yeah, if that's true that makes life much easier - I'll give it a try

@coveralls
Copy link

coveralls commented Dec 3, 2016

Coverage Status

Coverage increased (+0.07%) to 92.427% when pulling cfa8973 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

8 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.07%) to 92.427% when pulling cfa8973 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.07%) to 92.427% when pulling cfa8973 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.07%) to 92.427% when pulling cfa8973 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.07%) to 92.427% when pulling cfa8973 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.07%) to 92.427% when pulling cfa8973 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.07%) to 92.427% when pulling cfa8973 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.07%) to 92.427% when pulling cfa8973 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.07%) to 92.427% when pulling cfa8973 on brucek:http_driver_config into 7abe23c on neo4jrb:master.

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

Successfully merging this pull request may close these issues.

3 participants