You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by "rnewson (via GitHub)" <gi...@apache.org> on 2025/07/18 11:03:57 UTC
[PR] don't start gun if nouveau disabled [couchdb]
rnewson opened a new pull request, #5601:
URL: https://github.com/apache/couchdb/pull/5601
## Overview
ibrowse created connections on demand but gun creates them ahead of time. Prevent nouveau_gun from starting a connection pool when nouveau is disabled.
## Testing recommendations
## Related Issues or Pull Requests
<!-- If your changes affect multiple components in different
repositories please put links to those issues or pull requests here. -->
## Checklist
- [x] Code is written and works correctly
- [ ] Changes are covered by tests
- [ ] Any new configurable parameters are documented in `rel/overlay/etc/default.ini`
- [ ] Documentation changes were made in the `src/docs` folder
- [ ] Documentation changes were backported (separated PR) to affected branches
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] don't start gun if nouveau disabled [couchdb]
Posted by "nickva (via GitHub)" <gi...@apache.org>.
nickva commented on code in PR #5601:
URL: https://github.com/apache/couchdb/pull/5601#discussion_r2216377711
##########
src/nouveau/src/nouveau_gun.erl:
##########
@@ -36,20 +36,32 @@
-define(NOUVEAU_HOST_HEADER, nouveau_host_header).
+-record(state, {
+ enabled,
+ url
+}).
+
start_link() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
host_header() ->
persistent_term:get(?NOUVEAU_HOST_HEADER).
init(_) ->
+ Enabled = nouveau:enabled(),
URL = nouveau_util:nouveau_url(),
- case start_gun(URL) of
- {ok, _PoolPid} ->
- ok = config:listen_for_changes(?MODULE, URL),
- {ok, nil};
- {error, Reason} ->
- {error, Reason}
+ State = #state{enabled = Enabled, url = URL},
+ ok = config:listen_for_changes(?MODULE, State),
+ if
+ Enabled ->
+ case start_gun(URL) of
+ {ok, _PoolPid} ->
+ {ok, nil};
+ {error, Reason} ->
+ {error, Reason}
+ end;
+ true ->
+ {ok, nil}
Review Comment:
Since we have to run basically the same logic in init and on reconfigure maybe just have a single maybe_start() or reconfigure() function that keeps track of the started `Url` and on reconfigure we check:
```erlang
case {Enabled, StartedUrl} of
{true, undefined} -> start(), set StartedUrl = Url;
{true, StartedUrl != Url, Url!=undefined} -> stop(), start(), set StartedUrl = Url;
{false, StartedUrl != undefined} -> stop(), set StartedUrl = undefined;
{true, Url = StartedUrl} -> ok;
{false, _} ok
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] don't start gun if nouveau disabled [couchdb]
Posted by "nickva (via GitHub)" <gi...@apache.org>.
nickva commented on code in PR #5601:
URL: https://github.com/apache/couchdb/pull/5601#discussion_r2216377711
##########
src/nouveau/src/nouveau_gun.erl:
##########
@@ -36,20 +36,32 @@
-define(NOUVEAU_HOST_HEADER, nouveau_host_header).
+-record(state, {
+ enabled,
+ url
+}).
+
start_link() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
host_header() ->
persistent_term:get(?NOUVEAU_HOST_HEADER).
init(_) ->
+ Enabled = nouveau:enabled(),
URL = nouveau_util:nouveau_url(),
- case start_gun(URL) of
- {ok, _PoolPid} ->
- ok = config:listen_for_changes(?MODULE, URL),
- {ok, nil};
- {error, Reason} ->
- {error, Reason}
+ State = #state{enabled = Enabled, url = URL},
+ ok = config:listen_for_changes(?MODULE, State),
+ if
+ Enabled ->
+ case start_gun(URL) of
+ {ok, _PoolPid} ->
+ {ok, nil};
+ {error, Reason} ->
+ {error, Reason}
+ end;
+ true ->
+ {ok, nil}
Review Comment:
Since we have to run basically the same logic in init and on reconfigure maybe just have a single `maybe_start()` or `reconfigure()` function that keeps track of the `StartedUrl` and on reconfigure we check:
```erlang
case {Enabled, StartedUrl} of
{true, undefined} -> start(Url), StartedUrl = Url;
{true, StartedUrl != Url} -> stop(), start(Url), StartedUrl = Url;
{false, StartedUrl != undefined} -> stop(), StartedUrl = undefined;
{true, Url = StartedUrl} -> ok;
{false, _} ok
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] don't start gun if nouveau disabled [couchdb]
Posted by "nickva (via GitHub)" <gi...@apache.org>.
nickva commented on code in PR #5601:
URL: https://github.com/apache/couchdb/pull/5601#discussion_r2216377711
##########
src/nouveau/src/nouveau_gun.erl:
##########
@@ -36,20 +36,32 @@
-define(NOUVEAU_HOST_HEADER, nouveau_host_header).
+-record(state, {
+ enabled,
+ url
+}).
+
start_link() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
host_header() ->
persistent_term:get(?NOUVEAU_HOST_HEADER).
init(_) ->
+ Enabled = nouveau:enabled(),
URL = nouveau_util:nouveau_url(),
- case start_gun(URL) of
- {ok, _PoolPid} ->
- ok = config:listen_for_changes(?MODULE, URL),
- {ok, nil};
- {error, Reason} ->
- {error, Reason}
+ State = #state{enabled = Enabled, url = URL},
+ ok = config:listen_for_changes(?MODULE, State),
+ if
+ Enabled ->
+ case start_gun(URL) of
+ {ok, _PoolPid} ->
+ {ok, nil};
+ {error, Reason} ->
+ {error, Reason}
+ end;
+ true ->
+ {ok, nil}
Review Comment:
Since we have to run basically the same logic in init and on reconfigure maybe just have a single `maybe_start()` or `reconfigure()` function that keeps track of the `StartedUrl` and on reconfigure we check:
```erlang
case {Enabled, StartedUrl} of
{true, undefined} -> start(), StartedUrl = Url;
{true, StartedUrl != Url, Url!=undefined} -> stop(), start(), StartedUrl = Url;
{false, StartedUrl != undefined} -> stop(), StartedUrl = undefined;
{true, Url = StartedUrl} -> ok;
{false, _} ok
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] don't start gun if nouveau disabled [couchdb]
Posted by "nickva (via GitHub)" <gi...@apache.org>.
nickva commented on code in PR #5601:
URL: https://github.com/apache/couchdb/pull/5601#discussion_r2216377711
##########
src/nouveau/src/nouveau_gun.erl:
##########
@@ -36,20 +36,32 @@
-define(NOUVEAU_HOST_HEADER, nouveau_host_header).
+-record(state, {
+ enabled,
+ url
+}).
+
start_link() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
host_header() ->
persistent_term:get(?NOUVEAU_HOST_HEADER).
init(_) ->
+ Enabled = nouveau:enabled(),
URL = nouveau_util:nouveau_url(),
- case start_gun(URL) of
- {ok, _PoolPid} ->
- ok = config:listen_for_changes(?MODULE, URL),
- {ok, nil};
- {error, Reason} ->
- {error, Reason}
+ State = #state{enabled = Enabled, url = URL},
+ ok = config:listen_for_changes(?MODULE, State),
+ if
+ Enabled ->
+ case start_gun(URL) of
+ {ok, _PoolPid} ->
+ {ok, nil};
+ {error, Reason} ->
+ {error, Reason}
+ end;
+ true ->
+ {ok, nil}
Review Comment:
Since we have to run basically the same logic in init and on reconfigure maybe just have a single `maybe_start()` or `reconfigure()` function that keeps track of the `StartedUrl` and on reconfigure we check:
```erlang
case {Enabled, StartedUrl} of
{true, undefined} -> start(), set StartedUrl = Url;
{true, StartedUrl != Url, Url!=undefined} -> stop(), start(), set StartedUrl = Url;
{false, StartedUrl != undefined} -> stop(), set StartedUrl = undefined;
{true, Url = StartedUrl} -> ok;
{false, _} ok
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] don't start gun if nouveau disabled [couchdb]
Posted by "nickva (via GitHub)" <gi...@apache.org>.
nickva commented on code in PR #5601:
URL: https://github.com/apache/couchdb/pull/5601#discussion_r2216377711
##########
src/nouveau/src/nouveau_gun.erl:
##########
@@ -36,20 +36,32 @@
-define(NOUVEAU_HOST_HEADER, nouveau_host_header).
+-record(state, {
+ enabled,
+ url
+}).
+
start_link() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
host_header() ->
persistent_term:get(?NOUVEAU_HOST_HEADER).
init(_) ->
+ Enabled = nouveau:enabled(),
URL = nouveau_util:nouveau_url(),
- case start_gun(URL) of
- {ok, _PoolPid} ->
- ok = config:listen_for_changes(?MODULE, URL),
- {ok, nil};
- {error, Reason} ->
- {error, Reason}
+ State = #state{enabled = Enabled, url = URL},
+ ok = config:listen_for_changes(?MODULE, State),
+ if
+ Enabled ->
+ case start_gun(URL) of
+ {ok, _PoolPid} ->
+ {ok, nil};
+ {error, Reason} ->
+ {error, Reason}
+ end;
+ true ->
+ {ok, nil}
Review Comment:
Since we have to run basically the same logic in init and on reconfigure maybe just have a single `maybe_start()` or `reconfigure()` function that keeps track of the `StartedUrl` and on reconfigure we check:
```erlang
case {Enabled, StartedUrl} of
{true, undefined} -> start(Url), StartedUrl = Url;
{true, Url} -> ok;
{false, undefined} -> ok
{true, _} -> stop(), start(Url), StartedUrl = Url;
{false, _} -> stop(), StartedUrl = undefined;
{false, _} ok
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] don't start gun if nouveau disabled [couchdb]
Posted by "nickva (via GitHub)" <gi...@apache.org>.
nickva commented on code in PR #5601:
URL: https://github.com/apache/couchdb/pull/5601#discussion_r2216377711
##########
src/nouveau/src/nouveau_gun.erl:
##########
@@ -36,20 +36,32 @@
-define(NOUVEAU_HOST_HEADER, nouveau_host_header).
+-record(state, {
+ enabled,
+ url
+}).
+
start_link() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
host_header() ->
persistent_term:get(?NOUVEAU_HOST_HEADER).
init(_) ->
+ Enabled = nouveau:enabled(),
URL = nouveau_util:nouveau_url(),
- case start_gun(URL) of
- {ok, _PoolPid} ->
- ok = config:listen_for_changes(?MODULE, URL),
- {ok, nil};
- {error, Reason} ->
- {error, Reason}
+ State = #state{enabled = Enabled, url = URL},
+ ok = config:listen_for_changes(?MODULE, State),
+ if
+ Enabled ->
+ case start_gun(URL) of
+ {ok, _PoolPid} ->
+ {ok, nil};
+ {error, Reason} ->
+ {error, Reason}
+ end;
+ true ->
+ {ok, nil}
Review Comment:
Since we have to run basically the same logic in init and on reconfigure maybe just have a single `maybe_start()` or `reconfigure()` function that keeps track of the `StartedUrl` and on reconfigure we check:
```erlang
case {Enabled, StartedUrl} of
{true, undefined} -> start(Url), StartedUrl = Url;
{true, StartedUrl != Url, Url!=undefined} -> stop(), start(Url), StartedUrl = Url;
{false, StartedUrl != undefined} -> stop(), StartedUrl = undefined;
{true, Url = StartedUrl} -> ok;
{false, _} ok
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] don't start gun if nouveau disabled [couchdb]
Posted by "nickva (via GitHub)" <gi...@apache.org>.
nickva commented on code in PR #5601:
URL: https://github.com/apache/couchdb/pull/5601#discussion_r2216377711
##########
src/nouveau/src/nouveau_gun.erl:
##########
@@ -36,20 +36,32 @@
-define(NOUVEAU_HOST_HEADER, nouveau_host_header).
+-record(state, {
+ enabled,
+ url
+}).
+
start_link() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
host_header() ->
persistent_term:get(?NOUVEAU_HOST_HEADER).
init(_) ->
+ Enabled = nouveau:enabled(),
URL = nouveau_util:nouveau_url(),
- case start_gun(URL) of
- {ok, _PoolPid} ->
- ok = config:listen_for_changes(?MODULE, URL),
- {ok, nil};
- {error, Reason} ->
- {error, Reason}
+ State = #state{enabled = Enabled, url = URL},
+ ok = config:listen_for_changes(?MODULE, State),
+ if
+ Enabled ->
+ case start_gun(URL) of
+ {ok, _PoolPid} ->
+ {ok, nil};
+ {error, Reason} ->
+ {error, Reason}
+ end;
+ true ->
+ {ok, nil}
Review Comment:
Since we have to run basically the same logic in init and on reconfigure maybe just have a single `maybe_start()` or `reconfigure()` function that keeps track of the `StartedUrl` and on reconfigure we check:
```erlang
case {Enabled, StartedUrl} of
{true, undefined} -> start(Url), StartedUrl = Url;
{true, Url} -> ok;
{false, undefined} -> ok
{true, _} -> stop(), start(Url), StartedUrl = Url;
{false, _} -> stop(), StartedUrl = undefined
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] don't start gun if nouveau disabled [couchdb]
Posted by "rnewson (via GitHub)" <gi...@apache.org>.
rnewson commented on code in PR #5601:
URL: https://github.com/apache/couchdb/pull/5601#discussion_r2219452353
##########
src/nouveau/src/nouveau_gun.erl:
##########
@@ -36,20 +36,32 @@
-define(NOUVEAU_HOST_HEADER, nouveau_host_header).
+-record(state, {
+ enabled,
+ url
+}).
+
start_link() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
host_header() ->
persistent_term:get(?NOUVEAU_HOST_HEADER).
init(_) ->
+ Enabled = nouveau:enabled(),
URL = nouveau_util:nouveau_url(),
- case start_gun(URL) of
- {ok, _PoolPid} ->
- ok = config:listen_for_changes(?MODULE, URL),
- {ok, nil};
- {error, Reason} ->
- {error, Reason}
+ State = #state{enabled = Enabled, url = URL},
+ ok = config:listen_for_changes(?MODULE, State),
+ if
+ Enabled ->
+ case start_gun(URL) of
+ {ok, _PoolPid} ->
+ {ok, nil};
+ {error, Reason} ->
+ {error, Reason}
+ end;
+ true ->
+ {ok, nil}
Review Comment:
nice ideas, updated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] don't start gun if nouveau disabled [couchdb]
Posted by "rnewson (via GitHub)" <gi...@apache.org>.
rnewson merged PR #5601:
URL: https://github.com/apache/couchdb/pull/5601
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org