Define an accessor for the chunk buffer config val
Project: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/50694278 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/50694278 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/50694278 Branch: refs/heads/master Commit: 506942784469d0a084536628e5285867ca29f5e2 Parents: c0b8850 Author: Adam Kocoloski <[email protected]> Authored: Tue Jul 21 09:57:24 2015 -0400 Committer: Adam Kocoloski <[email protected]> Committed: Wed Jul 22 16:57:49 2015 -0400 ---------------------------------------------------------------------- src/chttpd.erl | 16 ++++++++++++++++ src/chttpd_db.erl | 5 ++--- src/chttpd_view.erl | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/50694278/src/chttpd.erl ---------------------------------------------------------------------- diff --git a/src/chttpd.erl b/src/chttpd.erl index f6ce530..28e15b6 100644 --- a/src/chttpd.erl +++ b/src/chttpd.erl @@ -34,6 +34,10 @@ send_delayed_error/2, end_delayed_json_response/1, get_delayed_req/1]). +-export([ + chunked_response_buffer_size/0 +]). + -record(delayed_resp, { start_fun, req, @@ -994,3 +998,15 @@ stack_hash(Stack) -> with_default(undefined, Default) -> Default; with_default(Value, _) -> Value. + +%% @doc CouchDB uses a chunked transfer-encoding to stream responses to +%% _all_docs, _changes, _view and other similar requests. This configuration +%% value sets the maximum size of a chunk; the system will buffer rows in the +%% response until it reaches this threshold and then send all the rows in one +%% chunk to improve network efficiency. The default value is chosen so that +%% the assembled chunk fits into the default Ethernet frame size (some reserved +%% padding is necessary to accommodate the reporting of the chunk length). Set +%% this value to 0 to restore the older behavior of sending each row in a +%% dedicated chunk. +chunked_response_buffer_size() -> + config:get_integer("httpd", "chunked_response_buffer", 1490). http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/50694278/src/chttpd_db.erl ---------------------------------------------------------------------- diff --git a/src/chttpd_db.erl b/src/chttpd_db.erl index ea3879f..329217a 100644 --- a/src/chttpd_db.erl +++ b/src/chttpd_db.erl @@ -86,8 +86,7 @@ handle_changes_req1(#httpd{}=Req, Db) -> ChangesArgs = Args0#changes_args{ filter_fun = couch_changes:configure_filter(Raw, Style, Req, Db) }, - % Default to ~filling the payload of a standard Ethernet frame - Max = config:get_integer("httpd", "chunked_response_buffer", 1490), + Max = chttpd:chunked_response_buffer_size(), case ChangesArgs#changes_args.feed of "normal" -> T0 = os:timestamp(), @@ -604,7 +603,7 @@ all_docs_view(Req, Db, Keys, OP) -> Args = Args3#mrargs{preflight_fun=ETagFun}, Options = [{user_ctx, Req#httpd.user_ctx}], {ok, Resp} = couch_httpd:etag_maybe(Req, fun() -> - Max = config:get_integer("httpd", "chunked_response_buffer", 1490), + Max = chttpd:chunked_response_buffer_size(), VAcc0 = #vacc{db=Db, req=Req, threshold=Max}, fabric:all_docs(Db, Options, fun couch_mrview_http:view_cb/2, VAcc0, Args) end), http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/50694278/src/chttpd_view.erl ---------------------------------------------------------------------- diff --git a/src/chttpd_view.erl b/src/chttpd_view.erl index 009aa8f..bb98fec 100644 --- a/src/chttpd_view.erl +++ b/src/chttpd_view.erl @@ -53,7 +53,7 @@ design_doc_view(Req, Db, DDoc, ViewName, Keys) -> end, Args = Args0#mrargs{preflight_fun=ETagFun}, {ok, Resp} = couch_httpd:etag_maybe(Req, fun() -> - Max = config:get_integer("httpd", "chunked_response_buffer", 1490), + Max = chttpd:chunked_response_buffer_size(), VAcc0 = #vacc{db=Db, req=Req, threshold=Max}, fabric:query_view(Db, DDoc, ViewName, fun couch_mrview_http:view_cb/2, VAcc0, Args) end),
