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

refactor(core) using new events library #8715

Closed
wants to merge 225 commits into from
Closed
Show file tree
Hide file tree
Changes from 177 commits
Commits
Show all changes
225 commits
Select commit Hold shift + click to select a range
e241f6d
events frame/protocol
chronolaw Mar 10, 2022
b6afdb5
callback.lua
chronolaw Mar 10, 2022
2b5c72b
broker.lua
chronolaw Mar 10, 2022
aead4cf
client.lua
chronolaw Mar 10, 2022
757b533
client.lua
chronolaw Mar 10, 2022
619b07d
default opts for broker
chronolaw Mar 10, 2022
30be16b
post local event
chronolaw Mar 10, 2022
7576479
code clean for queue
chronolaw Mar 10, 2022
1f76e6c
poll simulate
chronolaw Mar 10, 2022
2ac81a4
clean broker
chronolaw Mar 15, 2022
3752d72
clean worker
chronolaw Mar 15, 2022
06e281f
change worker events in global.lua
chronolaw Mar 15, 2022
9e7576a
add worker events server in template
chronolaw Mar 15, 2022
47fc24b
add event config
chronolaw Mar 15, 2022
d660e81
nginx kong template
chronolaw Mar 15, 2022
e09b7f8
add events code into rockspec
chronolaw Mar 15, 2022
6139960
code clean
chronolaw Mar 16, 2022
ba458db
code clean
chronolaw Mar 16, 2022
2e32759
add config entry
chronolaw Mar 16, 2022
18f5143
localize assert
chronolaw Mar 16, 2022
0a629fe
move events code to another repo
chronolaw Mar 17, 2022
b9b6dd0
fix broker in template
chronolaw Mar 17, 2022
5dd74ce
try run github ci
chronolaw Mar 18, 2022
606021d
stream supports events
chronolaw Mar 21, 2022
ca3a618
use unified resty.events
chronolaw Mar 23, 2022
997ec27
change config params
chronolaw Mar 29, 2022
489e184
add resty events in requirements
chronolaw Mar 31, 2022
4280adc
fix rebase error
chronolaw Mar 31, 2022
e8b8468
conf events mechanism
chronolaw Mar 31, 2022
360c0b5
edit custom_nginx.template
chronolaw Apr 7, 2022
950b4ab
enable unix socket
chronolaw Apr 9, 2022
7fc820c
template clean
chronolaw Apr 13, 2022
4be06df
events frame/protocol
chronolaw Mar 10, 2022
5bfc4ec
callback.lua
chronolaw Mar 10, 2022
fd10345
broker.lua
chronolaw Mar 10, 2022
819c5d2
client.lua
chronolaw Mar 10, 2022
3136d49
client.lua
chronolaw Mar 10, 2022
7a687de
default opts for broker
chronolaw Mar 10, 2022
a5cc15c
post local event
chronolaw Mar 10, 2022
226a169
code clean for queue
chronolaw Mar 10, 2022
c7c3608
poll simulate
chronolaw Mar 10, 2022
69baeb9
clean broker
chronolaw Mar 15, 2022
9dd2919
clean worker
chronolaw Mar 15, 2022
c43a4a5
change worker events in global.lua
chronolaw Mar 15, 2022
d52389d
add worker events server in template
chronolaw Mar 15, 2022
7efa785
add event config
chronolaw Mar 15, 2022
78eb71f
nginx kong template
chronolaw Mar 15, 2022
3abec6d
add events code into rockspec
chronolaw Mar 15, 2022
481cebe
code clean
chronolaw Mar 16, 2022
57ed53b
code clean
chronolaw Mar 16, 2022
0b52ed1
add config entry
chronolaw Mar 16, 2022
18eec32
localize assert
chronolaw Mar 16, 2022
e9f7d10
move events code to another repo
chronolaw Mar 17, 2022
8a2acc4
fix broker in template
chronolaw Mar 17, 2022
ee1fc43
try run github ci
chronolaw Mar 18, 2022
0b74248
stream supports events
chronolaw Mar 21, 2022
11618f5
use unified resty.events
chronolaw Mar 23, 2022
f0590b2
change config params
chronolaw Mar 29, 2022
82db0b5
add resty events in requirements
chronolaw Mar 31, 2022
c15066d
fix rebase error
chronolaw Mar 31, 2022
6e6f071
conf events mechanism
chronolaw Mar 31, 2022
56b3437
edit custom_nginx.template
chronolaw Apr 7, 2022
8359c45
enable unix socket
chronolaw Apr 9, 2022
b9a58cd
template clean
chronolaw Apr 13, 2022
5ac79b2
fix confilct
chronolaw Apr 13, 2022
e5bcd8c
fix singleton.config
chronolaw Apr 14, 2022
43a47ca
enable new events by default
chronolaw Apr 15, 2022
14bf433
typofix in kong_defaults.lua
chronolaw Apr 15, 2022
867b771
events wrapper
chronolaw Apr 15, 2022
69c2499
use resty.events.compat
chronolaw Apr 15, 2022
a41acc7
fix template bug
chronolaw Apr 15, 2022
9495500
fix template bug
chronolaw Apr 15, 2022
fc8e72b
fix spec/fixtures/custom_nginx.template
chronolaw Apr 16, 2022
9ae57c4
fix 01-admin_api_spec.lua
chronolaw Apr 16, 2022
7d5023d
add healthcheckers.lua for test
chronolaw Apr 16, 2022
84683b0
kong.resty.healthcheck
chronolaw Apr 16, 2022
2ceb512
style fix
chronolaw Apr 16, 2022
7fbfcb7
fix 02-integration/03-db/11-postgres-ro_spec.lua
chronolaw Apr 18, 2022
83e3cde
fix 02-integration/03-db/11-postgres-ro_spec.lua
chronolaw Apr 18, 2022
971397e
fix test with new events library
chronolaw Apr 19, 2022
f4721cf
fix 11-dbless/01-respawn_spec.lua
chronolaw Apr 19, 2022
e485bbb
fix 04-admin_api/15-off_spec.lua
chronolaw Apr 19, 2022
daef21a
fix 05-proxy/01-proxy_spec.lua
chronolaw Apr 19, 2022
3f8a0e8
fix 06-invalidations/02-core_entities_invalidations_spec.lua
chronolaw Apr 19, 2022
42312b4
fix 05-proxy/04-plugins_triggering_spec.lua
chronolaw Apr 19, 2022
a011e86
fix 05-proxy/14-server_tokens_spec.lua
chronolaw Apr 19, 2022
da699ba
fix 05-proxy/10-balancer/05-recreate-request_spec.lua
chronolaw Apr 19, 2022
cc11eaf
try to build kong
chronolaw Apr 21, 2022
a14c3a2
update setup_env_github.sh
chronolaw Apr 21, 2022
e56886f
more sleep to pass tests
chronolaw Apr 22, 2022
4cb0423
change .requirements
chronolaw Apr 22, 2022
82b2f77
force build cache miss
chronolaw Apr 22, 2022
eb06326
wait nginx stop
chronolaw Apr 22, 2022
f33e272
use smaller time to wait
chronolaw Apr 22, 2022
9de8f33
no sleep in test cases
chronolaw Apr 22, 2022
0bf37c6
still use sleep
chronolaw Apr 22, 2022
7141389
try to switch to old events library
chronolaw Apr 22, 2022
5bf2525
test switch to old events
chronolaw Apr 22, 2022
28bd9f2
comments unused var
chronolaw Apr 22, 2022
4cde9dc
fix count test
chronolaw Apr 22, 2022
19b3b3d
fix count test
chronolaw Apr 22, 2022
e0ed39a
revert to new events
chronolaw Apr 22, 2022
4af7630
remove sleep in 03-db/11-postgres-ro_spec.lua
chronolaw Apr 22, 2022
7a789cf
remove sleep in 03-db/11-postgres-ro_spec.lua
chronolaw Apr 22, 2022
5e148bd
remove sleep in 05-proxy/02-router_spec.lua
chronolaw Apr 22, 2022
80824f1
remove sleep in 05-proxy/14-server_tokens_spec.lua
chronolaw Apr 22, 2022
54963f1
some clean in 02-core_entities_invalidations_spec.lua
chronolaw Apr 22, 2022
e3cb7cd
some clean
chronolaw Apr 22, 2022
47eab82
some clean
chronolaw Apr 22, 2022
79ad3c8
clean 05-proxy/04-plugins_triggering_spec.lua
chronolaw Apr 22, 2022
f3ba060
sleep in 05-proxy/06-ssl_spec.lua
chronolaw Apr 22, 2022
e7e1095
remove sleep in 11-dbless/01-respawn_spec.lua
chronolaw Apr 22, 2022
1ef69d4
style fix
chronolaw Apr 22, 2022
041525f
remove sleep in 10-balancer/05-recreate-request_spec.lua
chronolaw Apr 25, 2022
631d0da
remove sleep in 10-balancer/05-recreate-request_spec.lua
chronolaw Apr 25, 2022
4329280
remove sleep in 06-invalidations/02-core_entities_invalidations_spec.lua
chronolaw Apr 25, 2022
8c38a2c
fix 05-proxy/04-plugins_triggering_spec.lua
chronolaw Apr 25, 2022
b3fd64c
fix some test in 10-balancer/01-healthchecks_spec.lua
chronolaw Apr 25, 2022
e45423d
fix 10-balancer/04-round-robin_spec.lua
chronolaw Apr 25, 2022
a8d541e
fix 10-balancer/01-healthchecks_spec.lua
chronolaw Apr 25, 2022
5b31db6
fix 10-balancer/01-healthchecks_spec.lua
chronolaw Apr 25, 2022
83faebd
fix 10-balancer/04-round-robin_spec.lua
chronolaw Apr 25, 2022
1c70a5b
fix 10-balancer/01-healthchecks_spec.lua
chronolaw Apr 25, 2022
06e13c9
fix 10-balancer/05-recreate-request_spec.lua
chronolaw Apr 25, 2022
b68fcc9
fix 10-balancer/01-healthchecks_spec.lua
chronolaw Apr 25, 2022
0b2347e
change 10-balancer/01-healthchecks_spec.lua
chronolaw Apr 25, 2022
ded8fc4
fix 04-admin_api/15-off_spec.lua
chronolaw Apr 25, 2022
b012496
fix 10-balancer/01-healthchecks_spec.lua
chronolaw Apr 25, 2022
895c3ec
fix 10-balancer/01-healthchecks_spec.lua
chronolaw Apr 25, 2022
95c0d24
fix 10-balancer/01-healthchecks_spec.lua
chronolaw Apr 25, 2022
670b153
fix 10-balancer/01-healthchecks_spec.lua
chronolaw Apr 25, 2022
813fce0
fix 05-proxy/18-upstream_tls_spec.lu
chronolaw Apr 25, 2022
920cf41
fix 05-proxy/18-upstream_tls_spec.lua
chronolaw Apr 25, 2022
3e978b6
fix 02-cmd/12-hybrid_spec.lua
chronolaw Apr 25, 2022
2fadd46
sleep in 10-balancer/01-healthchecks_spec.lua
chronolaw Apr 25, 2022
6eb45b6
fix 02-cmd/12-hybrid_spec.lua
chronolaw Apr 25, 2022
e650be6
clean 02-cmd/12-hybrid_spec.lua
chronolaw Apr 25, 2022
a42905b
fix 09-hybrid_mode/01-sync_spec.lua
chronolaw Apr 25, 2022
dd2a739
XXX 10-balancer/01-healthchecks_spec.lua
chronolaw Apr 25, 2022
1cfa103
fix 14-request-termination/03-integration_spec.lua
chronolaw Apr 25, 2022
40e6b20
fix 36-request-transformer/02-access_spec.lua
chronolaw Apr 25, 2022
fb9a11d
fix 10-balancer/01-healthchecks_spec.lua
chronolaw Apr 25, 2022
2f5af17
fix 36-request-transformer/02-access_spec.lua
chronolaw Apr 25, 2022
3c28127
fix spec/02-integration/06-invalidations/02-core_entities_invalidatio…
chronolaw Apr 25, 2022
107e2b6
fix 01-healthchecks_spec.lua
chronolaw Apr 25, 2022
d02ce23
fix 12-hybrid_spec.lua
chronolaw Apr 25, 2022
7593116
fix 14-server_tokens_spec.lua
chronolaw Apr 25, 2022
a7dffbd
fix 18-upstream_tls_spec.lua
chronolaw Apr 25, 2022
e8c819b
fix 11-postgres-ro_spec.lua
chronolaw Apr 25, 2022
afa02a7
fix 02-core_entities_invalidations_spec.lua
chronolaw Apr 25, 2022
bf27c3f
fix 18-upstream_tls_spec.lua
chronolaw Apr 25, 2022
cc805b6
fix 18-upstream_tls_spec.lua
chronolaw Apr 25, 2022
61ccfce
fix 18-upstream_tls_spec.lua
chronolaw Apr 25, 2022
d1b1de3
fix 04-status_api_spec.lua
chronolaw Apr 26, 2022
288fa03
sleep 0.01 in 02-router_spec.lua
chronolaw Apr 26, 2022
707abce
clean 14-server_tokens_spec.lua
chronolaw Apr 26, 2022
449125a
11-postgres-ro_spec.lua
chronolaw Apr 26, 2022
9e0b308
11-postgres-ro_spec.lua
chronolaw Apr 26, 2022
6105bc7
02-router_spec.lua
chronolaw Apr 26, 2022
64f513f
02-router_spec.lua
chronolaw Apr 26, 2022
df97cb3
02-core_entities_invalidations_spec.lua
chronolaw Apr 26, 2022
2fffc9d
01-healthchecks_spec.lua
chronolaw Apr 26, 2022
dd2e20f
01-healthchecks_spec.lua
chronolaw Apr 26, 2022
ff4300f
debug 01-healthchecks_spec.lua
chronolaw Apr 26, 2022
89f5a5c
debug 01-healthchecks_spec.lua
chronolaw Apr 26, 2022
aa72f40
clean 01-healthchecks_spec.lua
chronolaw Apr 26, 2022
a2d32bc
flaky 01-healthchecks_spec.lua
chronolaw Apr 26, 2022
7eeb376
02-router_spec.lua
chronolaw Apr 26, 2022
d346592
01-healthchecks_spec.lua
chronolaw Apr 26, 2022
8c5688c
refresh build cache
chronolaw Apr 27, 2022
bc8e702
check 01-healthchecks_spec.lua
chronolaw Apr 28, 2022
7c26b90
01-healthchecks_spec.lua
chronolaw Apr 28, 2022
af4ff6b
12-hybrid_spec.lua
chronolaw Apr 28, 2022
21a2633
02-cmd/02-start_stop_spec.lua
chronolaw Apr 28, 2022
7b3feb7
01-healthchecks_spec.lua
chronolaw Apr 28, 2022
44e2856
fix makefile
chronolaw Apr 29, 2022
0fd27c7
23-rate-limiting/04-access_spec.lua
chronolaw Apr 29, 2022
ed2f26b
graceful exit in 02-start_stop_spec.lua
chronolaw May 4, 2022
e3c83fd
01-healthchecks_spec.lua
chronolaw May 4, 2022
65cc6d7
add logs to debug ci test
chronolaw May 4, 2022
86d225a
turn off debug log in test suites
chronolaw May 4, 2022
0aa369e
skip flaky case in 01-healthchecks_spec.lua
chronolaw May 5, 2022
5358a8b
try to figure out balancer error
chronolaw May 6, 2022
349dae6
wait 0.1 for unix socket ready
chronolaw May 6, 2022
312dc88
fix 02-router_spec.lua
chronolaw May 6, 2022
cca21a6
debug in balancer/round_robin.lua
chronolaw May 6, 2022
628649b
revert debug code
chronolaw May 6, 2022
dc496d4
02-core_entities_invalidations_spec.lua
chronolaw May 7, 2022
91ab127
clean .requirements
chronolaw May 9, 2022
af83d06
rename to legacy_worker_events
chronolaw May 9, 2022
9fb11c5
chekc boolean legacy_worker_events
chronolaw May 9, 2022
f2b6bbf
clean 11-postgres-ro_spec.lua
chronolaw May 10, 2022
30ff547
clean 11-postgres-ro_spec.lua
chronolaw May 10, 2022
9eaade5
clean 15-off_spec.lua
chronolaw May 10, 2022
b2d0b08
clean 02-router_spec.lua
chronolaw May 10, 2022
216f952
clean 04-plugins_triggering_spec.lua
chronolaw May 10, 2022
41c008e
clean 04-round-robin_spec.lua
chronolaw May 10, 2022
d0e2f3f
clean 05-recreate-request_spec.lua
chronolaw May 10, 2022
987cb41
04-plugins_triggering_spec.lua
chronolaw May 10, 2022
eb47f00
clean 14-server_tokens_spec.lua
chronolaw May 10, 2022
badb21a
no verbose test log
chronolaw May 10, 2022
9dc0b95
clean 18-upstream_tls_spec.lua
chronolaw May 10, 2022
62b53c1
luacheck 18-upstream_tls_spec.lua
chronolaw May 10, 2022
19860c8
clean 02-core_entities_invalidations_spec.lua
chronolaw May 11, 2022
0654dc5
clean 01-respawn_spec.lua
chronolaw May 11, 2022
4990387
clean 03-integration_spec.lua
chronolaw May 11, 2022
87c2f15
clean 02-access_spec.lua
chronolaw May 11, 2022
c7b5444
clean 01-healthchecks_spec.lua
chronolaw May 11, 2022
311fa25
clean 04-plugins_triggering_spec.lua
chronolaw May 11, 2022
c31866a
clean 01-healthchecks_spec.lua
chronolaw May 11, 2022
690d99c
clean 02-core_entities_invalidations_spec.lua
chronolaw May 11, 2022
5a90e34
try flaky in 01-healthchecks_spec.lua
chronolaw May 11, 2022
99a3350
01-healthchecks_spec.lua is still flaky
chronolaw May 11, 2022
a4afde5
sync up master
chronolaw May 21, 2022
58bde7a
tests(healthchecks) fix flaky 401 test (#8839)
locao May 22, 2022
8681de3
update 02-start_stop_spec.lua
chronolaw May 30, 2022
7f46e85
update kong_defaults.lua
chronolaw May 30, 2022
b2a67a1
update kong_defaults.lua
chronolaw May 30, 2022
374120e
update kong_defaults.lua
chronolaw May 30, 2022
523f084
fix event repo branch
chronolaw May 30, 2022
0c4bd5c
fix build-tools
chronolaw May 30, 2022
2fb901b
fix build-tools
chronolaw May 30, 2022
0701841
remove singletons
chronolaw May 31, 2022
22fb057
change events library to main branch
chronolaw Jun 2, 2022
408ca0a
fix 05-proxy/02-router_spec.lua
chronolaw Jun 2, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .ci/setup_env_github.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ LUAROCKS=$(dep_version RESTY_LUAROCKS_VERSION)
OPENSSL=$(dep_version RESTY_OPENSSL_VERSION)
PCRE=$(dep_version RESTY_PCRE_VERSION)
RESTY_LMDB=$(dep_version RESTY_LMDB_VERSION)
RESTY_EVENTS=$(dep_version RESTY_EVENTS_VERSION)


#---------
Expand All @@ -34,6 +35,7 @@ kong-ngx-build \
--luarocks $LUAROCKS \
--openssl $OPENSSL \
--resty-lmdb $RESTY_LMDB \
--resty-events $RESTY_EVENTS \
--pcre $PCRE \
--debug

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
with:
repository: Kong/kong-build-tools
path: kong-build-tools
ref: master
ref: feat/new_resty_events
Copy link
Member

Choose a reason for hiding this comment

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

This will almost certainly have to be changed before we can merge it, so leaving this comment as a reminder.


- name: Checkout go-pluginserver
if: steps.cache-deps.outputs.cache-hit != 'true'
Expand Down
1 change: 1 addition & 0 deletions .requirements
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ RESTY_LUAROCKS_VERSION=3.8.0
RESTY_OPENSSL_VERSION=1.1.1n
RESTY_PCRE_VERSION=8.45
RESTY_LMDB_VERSION=master
RESTY_EVENTS_VERSION=feat/rebased_new_apis # main refresh cache
LIBYAML_VERSION=0.2.5
KONG_BUILD_TOOLS_VERSION=4.25.3
KONG_NGINX_MODULE_BRANCH=0.2.1
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ RESTY_VERSION ?= `grep RESTY_VERSION $(KONG_SOURCE_LOCATION)/.requirements | awk
RESTY_LUAROCKS_VERSION ?= `grep RESTY_LUAROCKS_VERSION $(KONG_SOURCE_LOCATION)/.requirements | awk -F"=" '{print $$2}'`
RESTY_OPENSSL_VERSION ?= `grep RESTY_OPENSSL_VERSION $(KONG_SOURCE_LOCATION)/.requirements | awk -F"=" '{print $$2}'`
RESTY_PCRE_VERSION ?= `grep RESTY_PCRE_VERSION $(KONG_SOURCE_LOCATION)/.requirements | awk -F"=" '{print $$2}'`
KONG_BUILD_TOOLS ?= `grep KONG_BUILD_TOOLS_VERSION $(KONG_SOURCE_LOCATION)/.requirements | awk -F"=" '{print $$2}'`
#KONG_BUILD_TOOLS ?= `grep KONG_BUILD_TOOLS_VERSION $(KONG_SOURCE_LOCATION)/.requirements | awk -F"=" '{print $$2}'`
KONG_BUILD_TOOLS ?= feat/new_resty_events
Copy link
Member

Choose a reason for hiding this comment

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

See above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

acknowledge

GRPCURL_VERSION ?= 1.8.5
OPENRESTY_PATCHES_BRANCH ?= master
KONG_NGINX_MODULE_BRANCH ?= master
Expand Down
3 changes: 3 additions & 0 deletions kong-2.8.0-0.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,9 @@ build = {
["kong.plugins.azure-functions.handler"] = "kong/plugins/azure-functions/handler.lua",
["kong.plugins.azure-functions.schema"] = "kong/plugins/azure-functions/schema.lua",

-- XXX: test only
Copy link
Member

Choose a reason for hiding this comment

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

So, remove before merging?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, Vini is working on new version health check library.

["kong.resty.healthcheck"] = "kong/resty/healthcheck.lua",

["kong.vaults.env"] = "kong/vaults/env/init.lua",
["kong.vaults.env.schema"] = "kong/vaults/env/schema.lua",
}
Expand Down
2 changes: 2 additions & 0 deletions kong/conf_loader/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,8 @@ local CONF_INFERENCES = {

lmdb_environment_path = { typ = "string" },
lmdb_map_size = { typ = "string" },

events_mechanism = { typ = "string" },
chronolaw marked this conversation as resolved.
Show resolved Hide resolved
}


Expand Down
43 changes: 35 additions & 8 deletions kong/global.lua
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,43 @@ end
function _GLOBAL.init_worker_events()
-- Note: worker_events will not work correctly if required at the top of the file.
-- It must be required right here, inside the init function
local worker_events = require "resty.worker.events"
local worker_events
local opts

local ok, err = worker_events.configure {
shm = "kong_process_events", -- defined by "lua_shared_dict"
timeout = 5, -- life time of event data in shm
interval = 1, -- poll interval (seconds)
local singletons = require "kong.singletons"
Copy link
Member

Choose a reason for hiding this comment

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

Instead of using singletons, can we in any way use the global kong, or do we have it ready at this point (e.g. kong.worker_events or kong.events?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I checked the kong's code and have no idea about how to get the conf var, so I have to use kong.singletons, Do you know a better solution for it?


wait_interval = 0.010, -- wait before retry fetching event data
wait_max = 0.5, -- max wait time before discarding event
}
if singletons.configuration and
singletons.configuration.events_mechanism == "shared_dict" then

opts = {
shm = "kong_process_events", -- defined by "lua_shared_dict"
timeout = 5, -- life time of event data in shm
interval = 1, -- poll interval (seconds)

wait_interval = 0.010, -- wait before retry fetching event data
wait_max = 0.5, -- max wait time before discarding event
}

worker_events = require "resty.worker.events"
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather have the two requires at the top of the file, even if that means having to use some temp var names here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

worker_events will not work correctly if required at the top of the file, It must be required right here, inside the init function


else
local sock_name = "worker_events.sock"
if ngx.config.subsystem == "stream" then
sock_name = "stream_" .. sock_name
end

opts = {
unique_timeout = 5, -- life time of unique event data in lrucache
broker_id = 0, -- broker server runs in nginx worker #0
listening = "unix:" .. -- unix socket for broker listening
ngx.config.prefix() .. sock_name,
}

--worker_events = require "resty.events"
worker_events = require "resty.events.compat"
Copy link
Member

Choose a reason for hiding this comment

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

Even when we load the compat module, should we make Kong to use new APIs everywhere in our code base. I do think we want to get rid of compat, and also people use our sources as an example, we should use the new api everywhere and just have compat there for custom plugins (and perhaps in case we missed to change something)? (Edit: I see this PR is not currently using the lib that has a new API, so just a reminder then).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the new API is a breaking change, we need to change many code in kong. Now I create this compatible layer only to try pass ci test.

end

local ok, err = worker_events.configure(opts)
if not ok then
return nil, err
end
Expand Down
Loading