Skip to content

Commit 8d391f5

Browse files
change: remove lua-resty-worker-events
Signed-off-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>
1 parent 4bc4e2c commit 8d391f5

File tree

13 files changed

+13
-742
lines changed

13 files changed

+13
-742
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ jobs:
2828
- ubuntu-latest
2929
os_name:
3030
- linux_openresty
31-
events_module:
32-
- lua-resty-worker-events
33-
- lua-resty-events
3431
test_dir:
3532
- t/plugin/[a-k]*.t
3633
- t/stream-plugin t/plugin/[l-z]*.t
@@ -170,7 +167,6 @@ jobs:
170167
- name: Linux Script
171168
env:
172169
TEST_FILE_SUB_DIR: ${{ matrix.test_dir }}
173-
TEST_EVENTS_MODULE: ${{ matrix.events_module }}
174170
run: sudo -E ./ci/${{ matrix.os_name }}_runner.sh script
175171

176172
- if: ${{ steps.cache-images.outputs.cache-hit != 'true' }}

.github/workflows/redhat-ci.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ jobs:
2323
strategy:
2424
fail-fast: false
2525
matrix:
26-
events_module:
27-
- lua-resty-worker-events
28-
- lua-resty-events
2926
test_dir:
3027
- t/plugin/[a-k]*
3128
- t/plugin/[l-z]*
@@ -120,9 +117,8 @@ jobs:
120117
- name: Run redhat docker and mapping apisix into container
121118
env:
122119
TEST_FILE_SUB_DIR: ${{ matrix.test_dir }}
123-
TEST_EVENTS_MODULE: ${{ matrix.events_module }}
124120
run: |
125-
docker run -itd -v ${{ github.workspace }}:/apisix --env TEST_FILE_SUB_DIR="$TEST_FILE_SUB_DIR" --env TEST_EVENTS_MODULE="$TEST_EVENTS_MODULE" --name ubiInstance --net="host" --dns 8.8.8.8 --dns-search apache.org registry.access.redhat.com/ubi8/ubi:8.6 /bin/bash
121+
docker run -itd -v ${{ github.workspace }}:/apisix --env TEST_FILE_SUB_DIR="$TEST_FILE_SUB_DIR" --name ubiInstance --net="host" --dns 8.8.8.8 --dns-search apache.org registry.access.redhat.com/ubi8/ubi:8.6 /bin/bash
126122
127123
- name: Cache images
128124
id: cache-images

apisix/cli/config.lua

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ local _M = {
7777
enable_encrypt_fields = true,
7878
keyring = { "qeddd145sfvddff3", "edd1c9f0985e76a2" }
7979
},
80-
events = {
81-
module = "lua-resty-events"
82-
},
8380
lru = {
8481
secret = {
8582
ttl = 300,

apisix/cli/ngx_tpl.lua

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ stream {
211211
apisix.stream_init_worker()
212212
}
213213
214-
{% if (events.module or "") == "lua-resty-events" then %}
215214
# the server block for lua-resty-events
216215
server {
217216
listen unix:{*apisix_lua_home*}/logs/stream_worker_events.sock;
@@ -220,7 +219,6 @@ stream {
220219
require("resty.events.compat").run()
221220
}
222221
}
223-
{% end %}
224222
225223
server {
226224
{% for _, item in ipairs(stream_proxy.tcp or {}) do %}
@@ -532,7 +530,6 @@ http {
532530
apisix.http_exit_worker()
533531
}
534532
535-
{% if (events.module or "") == "lua-resty-events" then %}
536533
# the server block for lua-resty-events
537534
server {
538535
listen unix:{*apisix_lua_home*}/logs/worker_events.sock;
@@ -543,7 +540,6 @@ http {
543540
}
544541
}
545542
}
546-
{% end %}
547543
548544
{% if enable_control then %}
549545
server {

apisix/events.lua

Lines changed: 9 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,10 @@ local ngx = ngx
2525
local core = require("apisix.core")
2626

2727
local _M = {
28-
events_module = nil,
2928
}
3029

31-
_M.EVENTS_MODULE_LUA_RESTY_WORKER_EVENTS = 'lua-resty-worker-events'
32-
_M.EVENTS_MODULE_LUA_RESTY_EVENTS = 'lua-resty-events'
33-
34-
35-
-- use lua-resty-worker-events
36-
local function init_resty_worker_events()
37-
_M.events_module = _M.EVENTS_MODULE_LUA_RESTY_WORKER_EVENTS
38-
39-
local we = require("resty.worker.events")
40-
local shm = ngx.config.subsystem == "http" and "worker-events" or "worker-events-stream"
41-
local ok, err = we.configure({shm = shm, interval = 0.1})
42-
if not ok then
43-
error("failed to init worker event: " .. err)
44-
end
45-
46-
return we
47-
end
48-
49-
5030
-- use lua-resty-events
5131
local function init_resty_events()
52-
_M.events_module = _M.EVENTS_MODULE_LUA_RESTY_EVENTS
53-
5432
local listening = "unix:" .. ngx.config.prefix() .. "logs/"
5533
if ngx.config.subsystem == "http" then
5634
listening = listening .. "worker_events.sock"
@@ -81,19 +59,7 @@ function _M.init_worker()
8159
end
8260

8361
_M.inited = true
84-
85-
local conf = core.config.local_conf()
86-
local module_name = core.table.try_read_attr(conf, "apisix", "events", "module")
87-
or _M.EVENTS_MODULE_LUA_RESTY_WORKER_EVENTS
88-
89-
if module_name == _M.EVENTS_MODULE_LUA_RESTY_EVENTS then
90-
-- use lua-resty-events as an event module via the apisix.events.module
91-
-- key in the configuration file
92-
_M.worker_events = init_resty_events()
93-
else
94-
-- use lua-resty-worker-events default now
95-
_M.worker_events = init_resty_worker_events()
96-
end
62+
_M.worker_events = init_resty_events()
9763
end
9864

9965

@@ -105,20 +71,15 @@ end
10571
function _M.event_list(self, source, ...)
10672
-- a patch for the lua-resty-events to support event_list
10773
-- this snippet is copied from the lua-resty-worker-events lib
108-
if self.events_module == _M.EVENTS_MODULE_LUA_RESTY_EVENTS then
109-
local events = { _source = source }
110-
for _, event in pairs({...}) do
111-
events[event] = event
112-
end
113-
return setmetatable(events, {
114-
__index = function(_, key)
115-
error("event '"..tostring(key).."' is an unknown event", 2)
116-
end
117-
})
74+
local events = { _source = source }
75+
for _, event in pairs({...}) do
76+
events[event] = event
11877
end
119-
120-
-- the lua-resty-worker-events has a built-in event_list implementation
121-
return self.worker_events.event_list(source, ...)
78+
return setmetatable(events, {
79+
__index = function(_, key)
80+
error("event '"..tostring(key).."' is an unknown event", 2)
81+
end
82+
})
12283
end
12384

12485

@@ -127,13 +88,4 @@ function _M.post(self, ...)
12788
end
12889

12990

130-
function _M.get_healthcheck_events_module(self)
131-
if self.events_module == _M.EVENTS_MODULE_LUA_RESTY_EVENTS then
132-
return "resty.events"
133-
else
134-
return "resty.worker.events"
135-
end
136-
end
137-
138-
13991
return _M

apisix/healthcheck_manager.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ local function create_checker(up_conf)
6767
name = get_healthchecker_name(up_conf),
6868
shm_name = healthcheck_shdict_name,
6969
checks = up_conf.checks,
70-
events_module = events:get_healthcheck_events_module(),
70+
events_module = "resty.events",
7171
})
7272

7373
if not checker then

ci/linux_openresty_common_runner.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ script() {
9292
start_sse_server_example
9393

9494
# APISIX_ENABLE_LUACOV=1 PERL5LIB=.:$PERL5LIB prove -Itest-nginx/lib -r t
95-
FLUSH_ETCD=1 TEST_EVENTS_MODULE=$TEST_EVENTS_MODULE prove --timer -Itest-nginx/lib -I./ -r $TEST_FILE_SUB_DIR | tee /tmp/test.result
95+
FLUSH_ETCD=1 prove --timer -Itest-nginx/lib -I./ -r $TEST_FILE_SUB_DIR | tee /tmp/test.result
9696
fail_on_bailout /tmp/test.result
9797
rerun_flaky_tests /tmp/test.result
9898
}

ci/redhat-ci.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ run_case() {
101101
make init
102102
set_coredns
103103
# run test cases
104-
FLUSH_ETCD=1 TEST_EVENTS_MODULE=$TEST_EVENTS_MODULE prove --timer -Itest-nginx/lib -I./ -r ${TEST_FILE_SUB_DIR} | tee /tmp/test.result
104+
FLUSH_ETCD=1 prove --timer -Itest-nginx/lib -I./ -r ${TEST_FILE_SUB_DIR} | tee /tmp/test.result
105105
fail_on_bailout /tmp/test.result
106106
rerun_flaky_tests /tmp/test.result
107107
}

conf/config.yaml.example

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,6 @@ apisix:
132132
# with the new key. Removing the old keys directly can render the data
133133
# unrecoverable.
134134

135-
events: # Event distribution module configuration
136-
module: lua-resty-events # Sets the name of the events module used.
137-
# Supported module: lua-resty-worker-events and lua-resty-events
138135
# status: # When enabled, APISIX will provide `/status` and `/status/ready` endpoints
139136
# ip: 127.0.0.1 # /status endpoint will return 200 status code if APISIX has successfully started and running correctly
140137
# port: 7085 # /status/ready endpoint will return 503 status code if any of the workers do not receive config from etcd

t/APISIX.pm

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,12 @@ if ($custom_dns_server) {
7878
}
7979

8080

81-
my $events_module = $ENV{TEST_EVENTS_MODULE} // "lua-resty-events";
8281
my $test_default_config = <<_EOC_;
8382
-- read the default configuration, modify it, and the Lua package
8483
-- cache will persist it for loading by other entrypoints
8584
-- it is used to replace the test::nginx implementation
8685
local default_config = require("apisix.cli.config")
8786
default_config.plugin_attr.prometheus.enable_export_server = false
88-
default_config.apisix.events.module = "$events_module"
8987
_EOC_
9088

9189
my $user_yaml_config = read_file("conf/config.yaml");

0 commit comments

Comments
 (0)