Skip to content

Commit 5c018f9

Browse files
committed
rename async example to tokio
To reduce some confusion. Since this example was introduced, we introduced a smaller nginx-native async executor directly to ngx
1 parent cbf33dd commit 5c018f9

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

.github/workflows/nginx.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ env:
4949
5050
NGX_TEST_FILES: examples/t
5151
NGX_TEST_GLOBALS_DYNAMIC: >-
52-
load_module ${{ github.workspace }}/nginx/objs/ngx_http_async_module.so;
52+
load_module ${{ github.workspace }}/nginx/objs/ngx_http_tokio_module.so;
5353
load_module ${{ github.workspace }}/nginx/objs/ngx_http_awssigv4_module.so;
5454
load_module ${{ github.workspace }}/nginx/objs/ngx_http_curl_module.so;
5555
load_module ${{ github.workspace }}/nginx/objs/ngx_http_shared_dict_module.so;

examples/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ path = "upstream.rs"
4747
crate-type = ["cdylib"]
4848

4949
[[example]]
50-
name = "async"
51-
path = "async.rs"
50+
name = "tokio"
51+
path = "tokio.rs"
5252
crate-type = ["cdylib"]
5353

5454
[[example]]

examples/config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ if [ $HTTP = YES ]; then
1616
ngx_rust_target_features=
1717

1818
if :; then
19-
ngx_module_name=ngx_http_async_module
19+
ngx_module_name=ngx_http_tokio_module
2020
ngx_module_libs="-lm"
21-
ngx_rust_target_name=async
21+
ngx_rust_target_name=tokio
2222

2323
ngx_rust_module
2424
fi

examples/t/async.t renamed to examples/t/tokio.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ http {
3939
server_name localhost;
4040
4141
location / {
42-
async on;
42+
tokio on;
4343
}
4444
}
4545
}

examples/async.conf renamed to examples/tokio.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ daemon off;
22
master_process off;
33
# worker_processes 1;
44

5-
load_module modules/libasync.so;
5+
load_module modules/libtokio.so;
66
error_log error.log debug;
77

88
events { }
@@ -14,7 +14,7 @@ http {
1414
location / {
1515
root html;
1616
index index.html index.htm;
17-
async on;
17+
tokio on;
1818
}
1919
error_page 500 502 503 504 /50x.html;
2020
location = /50x.html {

examples/async.rs renamed to examples/tokio.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct Module;
2020

2121
impl http::HttpModule for Module {
2222
fn module() -> &'static ngx_module_t {
23-
unsafe { &*::core::ptr::addr_of!(ngx_http_async_module) }
23+
unsafe { &*::core::ptr::addr_of!(ngx_http_tokio_module) }
2424
}
2525

2626
unsafe extern "C" fn postconfiguration(cf: *mut ngx_conf_t) -> ngx_int_t {
@@ -51,7 +51,7 @@ unsafe impl HttpModuleLocationConf for Module {
5151

5252
static mut NGX_HTTP_ASYNC_COMMANDS: [ngx_command_t; 2] = [
5353
ngx_command_t {
54-
name: ngx_string!("async"),
54+
name: ngx_string!("tokio"),
5555
type_: (NGX_HTTP_LOC_CONF | NGX_CONF_TAKE1) as ngx_uint_t,
5656
set: Some(ngx_http_async_commands_set_enable),
5757
conf: NGX_HTTP_LOC_CONF_OFFSET,
@@ -75,12 +75,12 @@ static NGX_HTTP_ASYNC_MODULE_CTX: ngx_http_module_t = ngx_http_module_t {
7575
// Generate the `ngx_modules` table with exported modules.
7676
// This feature is required to build a 'cdylib' dynamic module outside of the NGINX buildsystem.
7777
#[cfg(feature = "export-modules")]
78-
ngx::ngx_modules!(ngx_http_async_module);
78+
ngx::ngx_modules!(ngx_http_tokio_module);
7979

8080
#[used]
8181
#[allow(non_upper_case_globals)]
8282
#[cfg_attr(not(feature = "export-modules"), no_mangle)]
83-
pub static mut ngx_http_async_module: ngx_module_t = ngx_module_t {
83+
pub static mut ngx_http_tokio_module: ngx_module_t = ngx_module_t {
8484
ctx: std::ptr::addr_of!(NGX_HTTP_ASYNC_MODULE_CTX) as _,
8585
commands: unsafe { &NGX_HTTP_ASYNC_COMMANDS[0] as *const _ as *mut _ },
8686
type_: NGX_HTTP_MODULE as _,
@@ -149,7 +149,7 @@ http_request_handler!(async_access_handler, |request: &mut http::Request| {
149149
}
150150

151151
if let Some(ctx) =
152-
unsafe { request.get_module_ctx::<RequestCTX>(&*addr_of!(ngx_http_async_module)) }
152+
unsafe { request.get_module_ctx::<RequestCTX>(&*addr_of!(ngx_http_tokio_module)) }
153153
{
154154
if !ctx.done.load(Ordering::Relaxed) {
155155
return core::Status::NGX_AGAIN;
@@ -162,7 +162,7 @@ http_request_handler!(async_access_handler, |request: &mut http::Request| {
162162
if ctx.is_null() {
163163
return core::Status::NGX_ERROR;
164164
}
165-
request.set_module_ctx(ctx.cast(), unsafe { &*addr_of!(ngx_http_async_module) });
165+
request.set_module_ctx(ctx.cast(), unsafe { &*addr_of!(ngx_http_tokio_module) });
166166

167167
let ctx = unsafe { &mut *ctx };
168168
ctx.event.handler = Some(check_async_work_done);

0 commit comments

Comments
 (0)