-
Notifications
You must be signed in to change notification settings - Fork 1k
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
CouchDB 3.x: Move config options from [httpd] to [chttpd] #3567
CouchDB 3.x: Move config options from [httpd] to [chttpd] #3567
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @jiahuili430!
The PR looks great. Just a few cosmetic changes line lengths, a few boolean config switches, cleaning up chttpd_auth bits.
For new modules at least let's try to keep to a consistent style - line lengths less than 80 columns, proper whitespacing. A good way to check for those is to run Emilio (https://github.com/cloudant-labs/emilio).
Here is an example of a the type of output it might produce:
/Users/nvatama/asf (main) % ~/src/emilio/emilio ~/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:19(1) - 501 - line longer than 80 characters
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:20(1) - 501 - line longer than 80 characters
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:20(72) - 601 - underscore varibale _Persist reused
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:21(56) - 601 - underscore varibale _Persist reused
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:22(56) - 601 - underscore varibale _Persist reused
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:22(74) - 302 - there should be 2 empty lines between functions, not 1
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:26(58) - 601 - underscore varibale _Persist reused
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:27(51) - 601 - underscore varibale _Persist reused
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:28(52) - 601 - underscore varibale _Persist reused
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:28(70) - 302 - there should be 2 empty lines between functions, not 1
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:46(1) - 501 - line longer than 80 characters
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:50(1) - 501 - line longer than 80 characters
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:51(1) - 501 - line longer than 80 characters
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:55(7) - 302 - there should be 2 empty lines between functions, not 1
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:58(1) - 501 - line longer than 80 characters
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:59(1) - 501 - line longer than 80 characters
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:60(74) - 302 - there should be 2 empty lines between functions, not 1
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:64(1) - 501 - line longer than 80 characters
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:69(1) - 501 - line longer than 80 characters
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:70(75) - 302 - there should be 2 empty lines between functions, not 1
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:76(1) - 501 - line longer than 80 characters
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:76(95) - 302 - there should be 2 empty lines between functions, not 1
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:81(1) - 501 - line longer than 80 characters
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:83(1) - 501 - line longer than 80 characters
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:84(1) - 501 - line longer than 80 characters
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:84(93) - 302 - there should be 2 empty lines between functions, not 1
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:89(1) - 501 - line longer than 80 characters
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:91(63) - 302 - there should be 2 empty lines between functions, not 1
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:94(1) - 501 - line longer than 80 characters
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:94(104) - 302 - there should be 2 empty lines between functions, not 1
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:97(71) - 302 - there should be 2 empty lines between functions, not 1
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:100(1) - 501 - line longer than 80 characters
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:101(1) - 501 - line longer than 80 characters
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:102(1) - 501 - line longer than 80 characters
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:103(1) - 501 - line longer than 80 characters
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:104(1) - 501 - line longer than 80 characters
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:104(86) - 302 - there should be 2 empty lines between functions, not 1
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:107(1) - 501 - line longer than 80 characters
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:108(1) - 501 - line longer than 80 characters
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:109(1) - 501 - line longer than 80 characters
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:110(1) - 501 - line longer than 80 characters
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:110(119) - 302 - there should be 2 empty lines between functions, not 1
/Users/nvatama/asf-3/src/chttpd/test/eunit/chttpd_util_test.erl:112(1) - 501 - line longer than 80 characters
/Users/nvatama/asf (main) %
/Users/nvatama/asf (main) %
/Users/nvatama/asf (main) %
/Users/nvatama/asf (main) % ~/src/emilio/emilio ~/asf-3/src/chttpd/src/chttpd_util.erl
/Users/nvatama/asf-3/src/chttpd/src/chttpd_util.erl:17(26) - 130 - export at column 26, not 5
/Users/nvatama/asf-3/src/chttpd/src/chttpd_util.erl:18(34) - 130 - export at column 34, not 5
/Users/nvatama/asf-3/src/chttpd/src/chttpd_util.erl:19(31) - 130 - export at column 31, not 5
/Users/nvatama/asf-3/src/chttpd/src/chttpd_util.erl:25(49) - 302 - there should be 2 empty lines between functions, not 1
/Users/nvatama/asf-3/src/chttpd/src/chttpd_util.erl:29(58) - 302 - there should be 2 empty lines between functions, not 1
/Users/nvatama/asf-3/src/chttpd/src/chttpd_util.erl:31(1) - 501 - line longer than 80 characters
/Users/nvatama/asf-3/src/chttpd/src/chttpd_util.erl:33(66) - 302 - there should be 2 empty lines between functions, not 1
/Users/nvatama/asf-3/src/chttpd/src/chttpd_util.erl:35(1) - 501 - line longer than 80 characters
/Users/nvatama/asf-3/src/chttpd/src/chttpd_util.erl:37(66) - 302 - there should be 2 empty lines between functions, not 1
/Users/nvatama/asf-3/src/chttpd/src/chttpd_util.erl:41(60) - 302 - there should be 2 empty lines between functions, not 1
@jiahuili430 In the light of almost merging the erlfmt formatting PR, I think let's not worry about line length and emilio formatting as all that will be done automatically afterwards and it makes things simpler for you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor test fix-up and then +1
Great work @jiahuili430
src/chttpd/src/chttpd_util.erl
Outdated
]). | ||
|
||
|
||
get_chttpd_config(Key) when is_atom(Key) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the reason to use atom for keys?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To simplify the code. Otherwise, I need to use the key with quotation marks.
Thanks for the review.
src/chttpd/src/chttpd_util.erl
Outdated
config:get_integer("httpd", atom_to_list(Key), Default)). | ||
|
||
|
||
get_chttpd_config_boolean(Key, Default) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that previously we were doing something like:
config:get("httpd", "enable_cors", "false")
Similar to what @iilyak asked above, was there a specific reason you decided to convert the string key/value pairs into boolean/integer, but then convert them back to with atom_to_list
? Was it to make it more organized between different types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your review, considering the price of type conversion, I will change them back to strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @jiahuili430
Overview
Move some configuration options from
[httpd]
to[chttpd]
.The options are kept in [httpd]:
port
,bind_address
,authentication_handlers
,server_options
andsocket_options
.Since users have local settings, we cannot just move all options directly to
[chttpd]
.chttpd_util: get_chttpd_config()
will first check[chttpd]
, if it is not defined, it will check[httpd]
, and then, if it is not defined, it will return theDefault
value.I will add a documentation PR after when I finished moving options from
[couch_httpd_auth]
to[chttpd_auth]
.Testing recommendations
make eunit apps=chttpd suites=chttpd_util_test
Related Issues or Pull Requests
This fixes #3472
Checklist
rel/overlay/etc/default.ini