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

allow master defaults in connect #19

Merged
merged 2 commits into from
Oct 15, 2018
Merged

allow master defaults in connect #19

merged 2 commits into from
Oct 15, 2018

Conversation

motobob
Copy link

@motobob motobob commented Oct 15, 2018

allow setting defaults for connect options once in config and note upon every request.

@motobob
Copy link
Author

motobob commented Oct 15, 2018

@nalundgaard take a look. purposed on this is straight forward. motivation simplify life for erlcloud users like us

infinity),
connect_options = proplists:get_value(connect_options, Options, []),
connect_timeout = proplists:get_value(connect_timeout, Options, DefConTimeout),
connect_options = proplists:get_value(connect_options, Options, DefConOptions),

Choose a reason for hiding this comment

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

connect_options is a list. so for me it looks natural to merge DefConOptions and connect_options from Options, but not drop all DefConOptions in case any option is passed to execute() call.
current version will increase entropy of the universe.

Copy link
Author

Choose a reason for hiding this comment

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

fair enough. agree. will make it soon

Choose a reason for hiding this comment

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

+1 here.

@@ -150,6 +150,9 @@ execute(From, Host, Port, Ssl, Path, Method, Hdrs0, Body, Options) ->
%% Get a socket for the pool or exit
%Socket = lhttpc_manager:ensure_call(Pool, SocketRequest, Options),
Socket = lhttpc_manager:ensure_call(Pool, self(), Host, Port, Ssl, Options),
% get the socket connect settings from client or use defaults
DefConOptions = application:get_env(lhttpc, connect_options, []),
DefConTimeout = proplists:get_value(DefConOptions, connect_timeout, infinity),

Choose a reason for hiding this comment

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

This looks backwards. Please change to proplists:get_value(connect_timeout, DefConOptions, infinity).

Copy link
Author

Choose a reason for hiding this comment

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

(doh)

infinity),
connect_options = proplists:get_value(connect_options, Options, []),
connect_timeout = proplists:get_value(connect_timeout, Options, DefConTimeout),
connect_options = proplists:get_value(connect_options, Options, DefConOptions),

Choose a reason for hiding this comment

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

+1 here.

@motobob
Copy link
Author

motobob commented Oct 15, 2018

tested as

2> lists:ukeymerge(1, lists:ukeysort(1, proplists:unfold([foo, {bar, 500}])), lists:ukeysort(1, proplists:unfold([zzz, {bar,300}]))).
[{bar,500},{foo,true},{zzz,true}]
3>

@nalundgaard nalundgaard merged commit 5256584 into master Oct 15, 2018
@nalundgaard nalundgaard deleted the defaults4connect branch October 15, 2018 13:28
nalundgaard added a commit to erlcloud/erlcloud that referenced this pull request Oct 15, 2018
* Adds support for defaulting lhttpc connect_options via the OTP app configuration; see erlcloud/lhttpc#19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants