Skip to content

Commit cc10342

Browse files
committed
release 0.0.3
1 parent 0f80458 commit cc10342

5 files changed

Lines changed: 11 additions & 18 deletions

File tree

README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# lua-resty-socket ![Module Version][badge-version-image] [![Build Status][badge-travis-image]][badge-travis-url]
22

3-
A module to reconcile [ngx_lua]'s cosockets and LuaSocket.
3+
Graceful fallback to LuaSocket for [ngx_lua].
44

55
**Important note**: The use of LuaSocket inside ngx_lua is **strongly** discouraged due to the blocking nature of LuaSocket's `receive`. However, it does come handy at certain times when one is developing a lua-resty module and wants it to run in contexts that do not support cosockets (such as `init`). This module allows for a better compatibility between the APIs of both implementations, and should be used wisely.
66

@@ -24,23 +24,19 @@ local sock = socket.tcp()
2424
local is_luasocket = getmetatable(sock) == socket.luasocket_mt -- depends on surrounding context
2525

2626
local times, err = sock:getreusedtimes() -- 0 if underlying socket is LuaSocket
27-
-- ...
2827

2928
sock:settimeout(1000) -- converted to seconds if LuaSocket
3029

3130
local ok, err = sock:connect(host, port)
32-
-- ...
3331

3432
local ok, err = sock:sslhandshake(false, nil, false) -- cosocket signature, will use LuaSec if LuaSocket
35-
-- ...
3633

3734
local ok, err = sock:setkeepalive() -- close() if LuaSocket
38-
-- ...
3935
```
4036

4137
## Installation
4238

43-
This module is mainly intended to be copied and tweaked in a lua-resty library if its author is mad enough.
39+
This module is mainly intended to be copied in a lua-resty library and eventually modified to one's needs (such as desired supported contexts).
4440

4541
It can also be installed via LuaRocks:
4642

@@ -53,4 +49,4 @@ $ luarocks install lua-resty-socket
5349
[badge-travis-url]: https://travis-ci.org/thibaultCha/lua-resty-socket
5450
[badge-travis-image]: https://travis-ci.org/thibaultCha/lua-resty-socket.svg?branch=master
5551

56-
[badge-version-image]: https://img.shields.io/badge/version-0.0.2-blue.svg?style=flat
52+
[badge-version-image]: https://img.shields.io/badge/version-0.0.3-blue.svg?style=flat

lib/resty/socket.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
local get_phase, ngx_socket, has_cosocket, log, warn
2-
local type = type
3-
local rawget = rawget
42
local setmetatable = setmetatable
3+
local rawget = rawget
4+
local type = type
55

66
--- ngx_lua utils
77

@@ -107,5 +107,5 @@ return {
107107
}, luasocket_mt)
108108
end,
109109
luasocket_mt = luasocket_mt,
110-
_VERSION = "0.0.2"
110+
_VERSION = "0.0.3"
111111
}
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
package = "lua-resty-socket"
2-
version = "0.0.2-0"
2+
version = "0.0.3-0"
33
source = {
44
url = "git://github.com/thibaultCha/lua-resty-socket",
5-
tag = "0.0.2"
5+
tag = "0.0.3"
66
}
77
description = {
8-
summary = "A module offering interoperability between the LuaSocket and cosocket APIs",
8+
summary = "Graceful fallback to LuaSocket for ngx_lua",
99
homepage = "http://thibaultcha.github.io/lua-resty-socket",
1010
license = "MIT"
11-
}
12-
dependencies = {
13-
1411
}
1512
build = {
1613
type = "builtin",

spec/socket_spec.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe("resty.socket", function()
4040
end)
4141

4242
it("expose metadata", function()
43-
assert.equal("0.0.2", socket._VERSION)
43+
assert.equal("0.0.3", socket._VERSION)
4444
assert.is_table(socket.luasocket_mt)
4545
end)
4646
end)

t/00-sanity.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ __DATA__
2323
--- request
2424
GET /t
2525
--- response_body
26-
0.0.2
26+
0.0.3
2727
--- no_error_log
2828
[error]
2929

0 commit comments

Comments
 (0)