You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ngx_http_lua_module - Embed the power of Lua into Nginx HTTP Servers.
10
10
11
+
This module is a core component of OpenResty. If you are using this module, then you are essentially using OpenResty :)
12
+
11
13
*This module is not distributed with the Nginx source.* See [the installation instructions](#installation).
12
14
13
15
Table of Contents
@@ -61,7 +63,7 @@ Production ready.
61
63
Version
62
64
=======
63
65
64
-
This document describes ngx_lua [v0.10.13](https://github.com/openresty/lua-nginx-module/tags) released on 22 April 2018.
66
+
This document describes ngx_lua [v0.10.15](https://github.com/openresty/lua-nginx-module/tags) released on March 14th, 2019.
65
67
66
68
Synopsis
67
69
========
@@ -186,6 +188,8 @@ Synopsis
186
188
Description
187
189
===========
188
190
191
+
This module is a core component of OpenResty. If you are using this module, then you are essentially using OpenResty :)
192
+
189
193
This module embeds Lua, via [LuaJIT 2.0/2.1](http://luajit.org/luajit.html), into Nginx and by leveraging Nginx's subrequests, allows the integration of the powerful Lua threads (Lua coroutines) into the Nginx event model.
190
194
191
195
Unlike [Apache's mod_lua](https://httpd.apache.org/docs/trunk/mod/mod_lua.html) and [Lighttpd's mod_magnet](http://redmine.lighttpd.net/wiki/1/Docs:ModMagnet), Lua code executed using this module can be *100% non-blocking* on network traffic as long as the [Nginx API for Lua](#nginx-api-for-lua) provided by this module is used to handle
@@ -248,6 +252,8 @@ Nginx Compatibility
248
252
249
253
The latest version of this module is compatible with the following versions of Nginx:
250
254
255
+
* 1.15.x (last tested: 1.15.8)
256
+
* 1.14.x
251
257
* 1.13.x (last tested: 1.13.6)
252
258
* 1.12.x
253
259
* 1.11.x (last tested: 1.11.2)
@@ -956,7 +962,7 @@ This module is licensed under the BSD license.
956
962
957
963
Copyright (C) 2009-2017, by Xiaozhe Wang (chaoslawful) <chaoslawful@gmail.com>.
958
964
959
-
Copyright (C) 2009-2018, by Yichun "agentzh" Zhang (章亦春) <agentzh@gmail.com>, OpenResty Inc.
965
+
Copyright (C) 2009-2019, by Yichun "agentzh" Zhang (章亦春) <agentzh@gmail.com>, OpenResty Inc.
Retrieves the current request's request method name. Strings like `"GET"` and `"POST"` are returned instead of numerical [method constants](#http-method-constants).
Flushes out the expired items in the dictionary, up to the maximal number specified by the optional `max_count` argument. When the `max_count` argument is given `0` or not given at all, then it means unlimited. Returns the number of items that have actually been flushed.
6685
6745
6686
-
Unlike the [flush_all](#ngxshareddictflush_all) method, this method actually free up the memory used by the expired items.
6746
+
Unlike the [flush_all](#ngxshareddictflush_all) method, this method actually frees up the memory used by the expired items.
6687
6747
6688
6748
This feature was first introduced in the `v0.6.3` release.
6689
6749
@@ -7073,6 +7133,43 @@ An optional Lua table can be specified as the last argument to this method to sp
7073
7133
*`pool`
7074
7134
specify a custom name for the connection pool being used. If omitted, then the connection pool name will be generated from the string template `"<host>:<port>"` or `"<unix-socket-path>"`.
7075
7135
7136
+
*`pool_size`
7137
+
specify the size of the connection pool. If omitted and no
7138
+
`backlog` option was provided, no pool will be created. If omitted
7139
+
but `backlog` was provided, the pool will be created with a default
7140
+
size equal to the value of the [lua_socket_pool_size](#lua_socket_pool_size)
7141
+
directive.
7142
+
The connection pool holds up to `pool_size` alive connections
7143
+
ready to be reused by subsequent calls to [connect](#tcpsockconnect), but
7144
+
note that there is no upper limit to the total number of opened connections
7145
+
outside of the pool. If you need to restrict the total number of opened
7146
+
connections, specify the `backlog` option.
7147
+
When the connection pool would exceed its size limit, the least recently used
7148
+
(kept-alive) connection already in the pool will be closed to make room for
7149
+
the current connection.
7150
+
Note that the cosocket connection pool is per Nginx worker process rather
7151
+
than per Nginx server instance, so the size limit specified here also applies
7152
+
to every single Nginx worker process. Also note that the size of the connection
7153
+
pool cannot be changed once it has been created.
7154
+
This option was first introduced in the `v0.10.14` release.
7155
+
7156
+
*`backlog`
7157
+
if specified, this module will limit the total number of opened connections
7158
+
for this pool. No more connections than `pool_size` can be opened
7159
+
for this pool at any time. If the connection pool is full, subsequent
7160
+
connect operations will be queued into a queue equal to this option's
7161
+
value (the "backlog" queue).
7162
+
If the number of queued connect operations is equal to `backlog`,
7163
+
subsequent connect operations will fail and return `nil` plus the
7164
+
error string `"too many waiting connect operations"`.
7165
+
The queued connect operations will be resumed once the number of connections
7166
+
in the pool is less than `pool_size`.
7167
+
The queued connect operation will abort once they have been queued for more
7168
+
than `connect_timeout`, controlled by
7169
+
[settimeouts](#tcpsocksettimeouts), and will return `nil` plus
7170
+
the error string `"timeout"`.
7171
+
This option was first introduced in the `v0.10.14` release.
7172
+
7076
7173
The support for the options table argument was first introduced in the `v0.5.7` release.
7077
7174
7078
7175
This method was first introduced in the `v0.5.0rc1` release.
@@ -7218,7 +7315,7 @@ Timeout for the reading operation is controlled by the [lua_socket_read_timeout]
7218
7315
```lua
7219
7316
7220
7317
sock:settimeouts(1000, 1000, 1000) -- one second timeout for connect/read/write
7221
-
localdata, err=sock:receiveany(10*1024*1024) -- read any data, at most 10K
7318
+
localdata, err=sock:receiveany(10*1024) -- read any data, at most 10K
7222
7319
ifnotdatathen
7223
7320
ngx.say("failed to read any data: ", err)
7224
7321
return
@@ -7404,13 +7501,31 @@ Puts the current socket's connection immediately into the cosocket built-in conn
7404
7501
7405
7502
The first optional argument, `timeout`, can be used to specify the maximal idle timeout (in milliseconds) for the current connection. If omitted, the default setting in the [lua_socket_keepalive_timeout](#lua_socket_keepalive_timeout) config directive will be used. If the `0` value is given, then the timeout interval is unlimited.
7406
7503
7407
-
The second optional argument, `size`, can be used to specify the maximal number of connections allowed in the connection pool for the current server (i.e., the current host-port pair or the unix domain socket file path). Note that the size of the connection pool cannot be changed once the pool is created. When this argument is omitted, the default setting in the [lua_socket_pool_size](#lua_socket_pool_size) config directive will be used.
7408
-
7409
-
When the connection pool exceeds the available size limit, the least recently used (idle) connection already in the pool will be closed to make room for the current connection.
7410
-
7411
-
Note that the cosocket connection pool is per Nginx worker process rather than per Nginx server instance, so the size limit specified here also applies to every single Nginx worker process.
7412
-
7413
-
Idle connections in the pool will be monitored for any exceptional events like connection abortion or unexpected incoming data on the line, in which cases the connection in question will be closed and removed from the pool.
7504
+
The second optional argument `size` is considered deprecated since
7505
+
the `v0.10.14` release of this module, in favor of the
7506
+
`pool_size` option of the [connect](#tcpsockconnect) method.
7507
+
Since the `v0.10.14` release, this option will only take effect if
7508
+
the call to [connect](#tcpsockconnect) did not already create a connection
7509
+
pool.
7510
+
When this option takes effect (no connection pool was previously created by
7511
+
[connect](#tcpsockconnect)), it will specify the size of the connection pool,
7512
+
and create it.
7513
+
If omitted (and no pool was previously created), the default size is the value
7514
+
of the [lua_socket_pool_size](#lua_socket_pool_size) directive.
7515
+
The connection pool holds up to `size` alive connections ready to be
7516
+
reused by subsequent calls to [connect](#tcpsockconnect), but note that there
7517
+
is no upper limit to the total number of opened connections outside of the
7518
+
pool.
7519
+
When the connection pool would exceed its size limit, the least recently used
7520
+
(kept-alive) connection already in the pool will be closed to make room for
7521
+
the current connection.
7522
+
Note that the cosocket connection pool is per Nginx worker process rather
7523
+
than per Nginx server instance, so the size limit specified here also applies
7524
+
to every single Nginx worker process. Also note that the size of the connection
7525
+
pool cannot be changed once it has been created.
7526
+
If you need to restrict the total number of opened connections, specify both
7527
+
the `pool_size` and `backlog` option in the call to
7528
+
[connect](#tcpsockconnect).
7414
7529
7415
7530
In case of success, this method returns `1`; otherwise, it returns `nil` and a string describing the error.
0 commit comments