From ebf4ed02707060f93e3b4f9b7dc9439731d269e6 Mon Sep 17 00:00:00 2001 From: JianBo He Date: Tue, 31 May 2022 17:14:59 +0800 Subject: [PATCH] feat(connector-http): using pos_integer() instead of boolean() for enable_pipelining --- apps/emqx_connector/i18n/emqx_connector_http.conf | 6 +++--- apps/emqx_connector/src/emqx_connector_http.erl | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/emqx_connector/i18n/emqx_connector_http.conf b/apps/emqx_connector/i18n/emqx_connector_http.conf index 1f4435dae..0d92c269c 100644 --- a/apps/emqx_connector/i18n/emqx_connector_http.conf +++ b/apps/emqx_connector/i18n/emqx_connector_http.conf @@ -76,12 +76,12 @@ base URL 只包含host和port。
enable_pipelining { desc { - en: "Enable the HTTP pipeline." - zh: "允许HTTP管道。" + en: "Whether to send HTTP requests continuously, when set to 0, it means that after each HTTP request is sent, you need to wait for the server to return and then continue to send the next request." + zh: "是否连续发送 HTTP 请求,当设置为 0 时,表示每次发送完成 HTTP 请求后都需要等待服务器返回,再继续发送下一个请求。" } label: { en: "HTTP Pipelineing" - zh: "HTTP管道" + zh: "HTTP 管道" } } diff --git a/apps/emqx_connector/src/emqx_connector_http.erl b/apps/emqx_connector/src/emqx_connector_http.erl index b06ee94a8..128e5b810 100644 --- a/apps/emqx_connector/src/emqx_connector_http.erl +++ b/apps/emqx_connector/src/emqx_connector_http.erl @@ -54,6 +54,8 @@ pool_type/0 ]). +-define(DEFAULT_PIPELINE_SIZE, 100). + %%===================================================================== %% Hocon schema @@ -120,9 +122,9 @@ fields(config) -> )}, {enable_pipelining, sc( - boolean(), + pos_integer(), #{ - default => true, + default => ?DEFAULT_PIPELINE_SIZE, desc => ?DESC("enable_pipelining") } )}, @@ -210,7 +212,8 @@ on_start( {pool_type, PoolType}, {pool_size, PoolSize}, {transport, Transport}, - {transport_opts, NTransportOpts} + {transport_opts, NTransportOpts}, + {enable_pipelining, maps:get(enable_pipelining, Config, ?DEFAULT_PIPELINE_SIZE)} ], PoolName = emqx_plugin_libs_pool:pool_name(InstId), State = #{