Skip to content

allow master defaults in connect - #19

Merged
nalundgaard merged 2 commits into
masterfrom
defaults4connect
Oct 15, 2018
Merged

allow master defaults in connect#19
nalundgaard merged 2 commits into
masterfrom
defaults4connect

Conversation

@motobob

Copy link
Copy Markdown

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

@motobob

Copy link
Copy Markdown
Author

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

Comment threadsrc/lhttpc_client.erl Outdated
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),

Copy link
Copy Markdown

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
Copy Markdown
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

+1 here.

Comment threadsrc/lhttpc_client.erl Outdated
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),

Copy link
Copy Markdown

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
Copy Markdown
Author

Choose a reason for hiding this comment

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

(doh)

Comment threadsrc/lhttpc_client.erl Outdated
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),

Copy link
Copy Markdown

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
Copy Markdown
Author

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 masterOct 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 freeto 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

@motobob@nalundgaard@key-master