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

CouchDB 3.x: Move config options from [httpd] to [chttpd] #3567

Merged
merged 1 commit into from
May 24, 2021
Merged

CouchDB 3.x: Move config options from [httpd] to [chttpd] #3567

merged 1 commit into from
May 24, 2021

Conversation

jiahuili430
Copy link
Contributor

@jiahuili430 jiahuili430 commented May 17, 2021

Overview

Move some configuration options from [httpd] to [chttpd].
The options are kept in [httpd]: port, bind_address, authentication_handlers, server_options and socket_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 the Default 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

@jiahuili430 jiahuili430 changed the title CouchDB 3.x: Move config options from httpd to chttpd [WIP] CouchDB 3.x: Move config options from [httpd] to [chttpd] [WIP] May 17, 2021
@jiahuili430 jiahuili430 deleted the move-config-options-from-httpd-to-chttpd-main branch May 17, 2021 13:21
@jiahuili430 jiahuili430 restored the move-config-options-from-httpd-to-chttpd-main branch May 17, 2021 13:32
@bessbd bessbd reopened this May 17, 2021
@jiahuili430 jiahuili430 deleted the move-config-options-from-httpd-to-chttpd-main branch May 17, 2021 13:35
@jiahuili430 jiahuili430 restored the move-config-options-from-httpd-to-chttpd-main branch May 17, 2021 13:40
@jiahuili430 jiahuili430 reopened this May 17, 2021
rel/overlay/etc/default.ini Outdated Show resolved Hide resolved
rel/overlay/etc/default.ini Outdated Show resolved Hide resolved
rel/overlay/etc/default.ini Outdated Show resolved Hide resolved
rel/overlay/etc/default.ini Outdated Show resolved Hide resolved
rel/overlay/etc/default.ini Outdated Show resolved Hide resolved
rel/overlay/etc/default.ini Outdated Show resolved Hide resolved
rel/overlay/etc/default.ini Outdated Show resolved Hide resolved
rel/overlay/etc/default.ini Outdated Show resolved Hide resolved
rel/overlay/etc/default.ini Outdated Show resolved Hide resolved
rel/overlay/etc/default.ini Outdated Show resolved Hide resolved
src/chttpd/src/chttpd.erl Outdated Show resolved Hide resolved
rel/overlay/etc/default.ini Outdated Show resolved Hide resolved
@jiahuili430 jiahuili430 marked this pull request as ready for review May 19, 2021 22:06
src/chttpd/src/chttpd.erl Outdated Show resolved Hide resolved
Copy link
Contributor

@nickva nickva left a 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

rel/overlay/etc/default.ini Outdated Show resolved Hide resolved
@nickva nickva mentioned this pull request May 21, 2021
4 tasks
@nickva
Copy link
Contributor

nickva commented May 21, 2021

@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.

@jiahuili430 jiahuili430 changed the title CouchDB 3.x: Move config options from [httpd] to [chttpd] [WIP] CouchDB 3.x: Move config options from [httpd] to [chttpd] May 21, 2021
Copy link
Contributor

@nickva nickva left a 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/test/eunit/chttpd_util_test.erl Outdated Show resolved Hide resolved
src/chttpd/test/eunit/chttpd_util_test.erl Outdated Show resolved Hide resolved
]).


get_chttpd_config(Key) when is_atom(Key) ->
Copy link
Contributor

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?

Copy link
Contributor Author

@jiahuili430 jiahuili430 May 21, 2021

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.

config:get_integer("httpd", atom_to_list(Key), Default)).


get_chttpd_config_boolean(Key, Default)
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@nickva nickva left a comment

Choose a reason for hiding this comment

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

Nice work @jiahuili430

@nickva nickva merged commit f1dd5fe into apache:3.x May 24, 2021
@jiahuili430 jiahuili430 deleted the move-config-options-from-httpd-to-chttpd-main branch June 7, 2021 21:40
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.

5 participants