Skip to content

Commit

Permalink
With a hard-coded payload size, for some use cases like uploading a big
Browse files Browse the repository at this point in the history
OpenAPI spec in DevPortal or updating a big config entry for plugins,
they can not work as expected. With the new parameter, the user can
decide the payload size to meet their needs.

In this PR, a new parameter, `worker_events_max_payload` is added, which
allows to specify the payload size the `worker_events` lib can accept.
The default size is 64k, and the max allowed to set is 16M Bytes.

The corresponding PR for `worker_events` lib is [#37](Kong/lua-resty-events#37)

FTI-4963
  • Loading branch information
liverpool8056 authored and chronolaw committed Jul 14, 2023
1 parent c371931 commit ad3f18a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
5 changes: 5 additions & 0 deletions kong.conf.default
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@
# Similarly to `error_template_html`, the template
# is required to contain one single `%s` placeholder for
# the error message.

#worker_events_max_payload = # Specifies the max payload size the `worker_events` can
# accept.
# Default is 64k - 1024 * 64. The max allowed is 16M Bytes.

#------------------------------------------------------------------------------
# HYBRID MODE
#------------------------------------------------------------------------------
Expand Down
12 changes: 8 additions & 4 deletions kong/global.lua
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,21 @@ function _GLOBAL.init_worker_events()
and configuration.prefix
or require("pl.path").abspath(ngx.config.prefix())

local max_payload_len = configuration
and configuration.worker_events_max_payload

local sock = ngx.config.subsystem == "stream"
and "stream_worker_events.sock"
or "worker_events.sock"

local listening = "unix:" .. prefix .. "/" .. sock

opts = {
unique_timeout = 5, -- life time of unique event data in lrucache
broker_id = 0, -- broker server runs in nginx worker #0
listening = listening, -- unix socket for broker listening
max_queue_len = 1024 * 50, -- max queue len for events buffering
unique_timeout = 5, -- life time of unique event data in lrucache
broker_id = 0, -- broker server runs in nginx worker #0
listening = listening, -- unix socket for broker listening
max_payload_len = max_payload_len, -- max payload size in bytes
max_queue_len = 1024 * 50, -- max queue len for events buffering
}

worker_events = require "resty.events.compat"
Expand Down
1 change: 1 addition & 0 deletions kong/templates/kong_defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ cluster_dp_labels = NONE
lmdb_environment_path = dbless.lmdb
lmdb_map_size = 2048m
mem_cache_size = 128m
worker_events_max_payload = 64k
ssl_cert = NONE
ssl_cert_key = NONE
client_ssl = off
Expand Down

0 comments on commit ad3f18a

Please sign in to comment.