openresty/lua-resty-core

New FFI-based API for lua-nginx-module

LuaPerlMakefile
This is stars and forks stats for /openresty/lua-resty-core repository. As of 07 May, 2024 this repository has 751 stars and 267 forks.

Name lua-resty-core - New FFI-based Lua API for ngx_http_lua_module and/or ngx_stream_lua_module Table of Contents Name Status Synopsis Description Prerequisites API Implemented resty.core.hash resty.core.base64 resty.core.uri resty.core.regex resty.core.exit resty.core.shdict resty.core.var resty.core.ctx get_ctx_table resty.core.request resty.core.response resty.core.misc resty.core.time resty.core.worker resty.core.phase resty.core.ndk resty.core.socket resty.core.param ngx.semaphore ngx.balancer ngx.ssl ngx.ssl.clienthello ngx.ssl.session ngx.re ngx.resp ngx.pipe ngx.process ngx.errlog ngx.base64 Caveat TODO Author Copyright and License See Also Status This library is production ready. Synopsis This library is automatically loaded by default since OpenResty 1.15.8.1. This behavior can be disabled via the lua_load_resty_core directive, but note that the use of this library is vividly recommended, as its FFI implementation is both faster, safer, and more complete than the Lua C API of the ngx_lua module. If you are using an older version of OpenResty, you must load this library like so: # nginx.conf http { # you do NOT need to configure the following line when you # are using the OpenResty bundle 1.4.3.9+. lua_package_path "/path/to/lua-resty-core/lib/?.lua;;"; init_by_lua_block { require "resty.core" collectgarbage("collect") -- just to collect any garbage } ... } Description This pure Lua library reimplements part of the ngx_lua module's Nginx API for Lua with LuaJIT FFI and installs the new FFI-based Lua API into the ngx.* and ndk.* namespaces used by the ngx_lua module. In addition, this Lua library implements any significant new Lua APIs of the ngx_lua module as proper Lua modules, like ngx.semaphore and ngx.balancer. The FFI-based Lua API can work with LuaJIT's JIT compiler. ngx_lua's default API is based on the standard Lua C API, which will never be JIT compiled and the user Lua code is always interpreted (slowly). Support for the new ngx_stream_lua_module has also begun. This library is shipped with the OpenResty bundle by default. So you do not really need to worry about the dependencies and requirements. Back to TOC Prerequisites WARNING This library is included with every OpenResty release. You should use the bundled version of this library in the particular OpenResty release you are using. Otherwise you may run into serious compatibility issues. LuaJIT 2.1 (for now, it is the v2.1 git branch in the official luajit-2.0 git repository: http://luajit.org/download.html ) ngx_http_lua_module v0.10.25. ngx_stream_lua_module v0.0.13. lua-resty-lrucache Back to TOC API Implemented Back to TOC resty.core.hash ngx.md5 ngx.md5_bin ngx.sha1_bin Back to TOC resty.core.base64 ngx.encode_base64 ngx.decode_base64 Back to TOC resty.core.uri ngx.escape_uri ngx.unescape_uri Back to TOC resty.core.regex ngx.re.match ngx.re.gmatch ngx.re.find ngx.re.sub ngx.re.gsub Back to TOC resty.core.exit ngx.exit Back to TOC resty.core.shdict ngx.shared.DICT.get ngx.shared.DICT.get_stale ngx.shared.DICT.incr ngx.shared.DICT.set ngx.shared.DICT.safe_set ngx.shared.DICT.add ngx.shared.DICT.safe_add ngx.shared.DICT.replace ngx.shared.DICT.delete ngx.shared.DICT.ttl ngx.shared.DICT.expire ngx.shared.DICT.flush_all ngx.shared.DICT.free_space ngx.shared.DICT.capacity Back to TOC resty.core.var ngx.var.VARIABLE Back to TOC resty.core.ctx ngx.ctx Back to TOC get_ctx_table syntax: ctx = resty.core.ctx.get_ctx_table(ctx?) Similar to ngx.ctx but it accepts an optional ctx argument. It will use the ctx from caller instead of creating a new table when the ctx table does not exist. Notice: the ctx table will be used in the current request's whole life cycle. Please be very careful when you try to reuse the ctx table. You need to make sure there is no Lua code using or going to use the ctx table in the current request before you reusing the ctx table in some other place. Back to TOC resty.core.request ngx.req.get_headers ngx.req.get_uri_args ngx.req.start_time ngx.req.get_method ngx.req.set_method ngx.req.set_header ngx.req.clear_header Back to TOC resty.core.response ngx.header.HEADER Back to TOC resty.core.misc ngx.status ngx.is_subrequest ngx.headers_sent ngx.req.is_internal Back to TOC resty.core.time ngx.time ngx.now ngx.update_time ngx.localtime ngx.utctime ngx.cookie_time ngx.http_time ngx.parse_http_time monotonic_msec monotonic_time Back to TOC resty.core.worker ngx.worker.exiting ngx.worker.pid ngx.worker.id ngx.worker.count Back to TOC resty.core.phase ngx.get_phase Back to TOC resty.core.ndk ndk.set_var Back to TOC resty.core.socket socket.setoption socket.setclientcert socket.sslhandshake Back to TOC resty.core.param ngx.arg (getter only) Back to TOC ngx.semaphore This Lua module implements a semaphore API for efficient "light thread" synchronization, which can work across different requests (but not across nginx worker processes). See the documentation for this Lua module for more details. Back to TOC ngx.balancer This Lua module implements for defining dynamic upstream balancers in Lua. See the documentation for this Lua module for more details. Back to TOC ngx.ssl This Lua module provides a Lua API for controlling SSL certificates, private keys, SSL protocol versions, and etc in NGINX downstream SSL handshakes. See the documentation for this Lua module for more details. Back to TOC ngx.ssl.clienthello This Lua module provides a Lua API for post-processing SSL client hello message for NGINX downstream SSL connections. See the documentation for this Lua module for more details. Back to TOC ngx.ssl.session This Lua module provides a Lua API for manipulating SSL session data and IDs for NGINX downstream SSL connections. See the documentation for this Lua module for more details. Back to TOC ngx.re This Lua module provides a Lua API which implements convenience utilities for the ngx.re API. See the documentation for this Lua module for more details. Back to TOC ngx.resp This Lua module provides Lua API which could be used to handle HTTP response. See the documentation for this Lua module for more details. Back to TOC ngx.pipe This module provides a Lua API to spawn processes and communicate with them in a non-blocking fashion. See the documentation for this Lua module for more details. This module was first introduced in lua-resty-core v0.1.16. Back to TOC ngx.process This Lua module is used to manage the nginx process in Lua. See the documentation for this Lua module for more details. This module was first introduced in lua-resty-core v0.1.12. Back to TOC ngx.errlog This Lua module provides Lua API to capture and manage nginx error log messages. See the documentation for this Lua module for more details. This module was first introduced in lua-resty-core v0.1.12. Back to TOC ngx.base64 This Lua module provides Lua API to urlsafe base64 encode/decode. See the documentation for this Lua module for more details. This module was first introduced in lua-resty-core v0.1.14. Back to TOC Caveat If the user Lua code is not JIT compiled, then use of this library may lead to performance drop in interpreted mode. You will only observe speedup when you get a good part of your user Lua code JIT compiled. Back to TOC TODO Re-implement ngx_lua's cosocket API with FFI. Re-implement ngx_lua's ngx.eof and ngx.flush API functions with FFI. Back to TOC Author Yichun "agentzh" Zhang (章亦春) [email protected], OpenResty Inc. Back to TOC Copyright and License This module is licensed under the BSD license. Copyright (C) 2013-2019, by Yichun "agentzh" Zhang, OpenResty Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Back to TOC See Also the ngx_lua module: https://github.com/openresty/lua-nginx-module#readme LuaJIT FFI: http://luajit.org/ext_ffi.html Back to TOC
Read on GithubGithub Stats Page
repotechsstarsweeklyforksweekly
kevinhwang91/nvim-hlslensLuaOther626080
andweeb/presence.nvimLuaVim Script632+4410
tjdevries/colorbuddy.nvimLuaHTMLOther5180160
swedishembedded/controlMATLABPerlC760190
eaobservatory/perl-JCMT-ACSIS-ArrayPerl1000
mrmckain/Genomic_ProcessingPerl1000
supabase/vaultPLpgSQLShellDockerfile149060
nicolargo/glancesPythonVueMakefile23.6k01.4k0
docker/docker-installShellMakefile1.8k07660
determined-ai/determinedGoPythonTypeScript2.5k03210