Skip to content

Commit 2ec1274

Browse files
committed
Updated README.md
1 parent e376305 commit 2ec1274

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Lua Pubsub client driver for the `ngx_lua` based on the cosocket API
44

55
## Table of Contents
66

7-
* [Name](#name)
87
* [Description](#description)
98
* [Synopsis](#synopsis)
109
* [Configs](#configs)
@@ -24,7 +23,7 @@ Lua Pubsub client driver for the `ngx_lua` based on the cosocket API
2423

2524
This Lua library is a Pubsub client driver for the ngx_lua nginx module: http://wiki.nginx.org/HttpLuaModule
2625

27-
This Lua library takes advantage of ngx_lua's cosocket API, which ensures 100% nonblocking behavior. This library pushes messages (with attributes) to Google Cloud pubsub using nginx timers and http
26+
This Lua library takes advantage of ngx_lua's cosocket API, which ensures 100% nonblocking behavior. This library pushes messages (with attributes) to Google Cloud pubsub using nginx timers and http requests.
2827

2928
Note that at least [ngx_lua 0.9.3](https://github.com/openresty/lua-nginx-module/tags) or [ngx_openresty 1.4.3.7](http://openresty.org/#Download) is required, and unfortunately only LuaJIT supported (`--with-luajit`).
3029

@@ -102,17 +101,24 @@ Note that at least [ngx_lua 0.9.3](https://github.com/openresty/lua-nginx-module
102101
local producer, err = pubsub_producer:new(project_id, pubsub_config, producer_config,
103102
oauth_config, success_callback, error_callback, oauth_setter, oauth_getter)
104103

104+
-- Also check if there is any error while initializing producer
105105
if err ~= nil then
106106
ngx.log(ngx.ERR, "Unable to create producer ", err)
107107
return
108108
end
109109

110-
-- Finally send the message with attributes
111-
producer:send("Some Random Text", {
110+
-- Finally send the message with attributes.
111+
local ok, send_err = producer:send("Some Random Text", {
112112
attr1 = "Test1",
113113
attr2 = "Test2"
114114
})
115115

116+
-- Also check if there is any error while sending message
117+
if send_err ~= nil then
118+
ngx.log(ngx.ERR, "Unable to send data to pubsub: ", send_err)
119+
return
120+
end
121+
116122
end
117123

118124
-- Publish Message
@@ -186,7 +192,7 @@ Example
186192
"http_timeout" : 6000,
187193
"keepalive_max_idle_timeout" : 2000,
188194
"keepalive_pool_size" : 50
189-
}
195+
}
190196
```
191197

192198
A `oauth_config` table needs to be specified which is used for generating the oauth 2.0 verification for http request. It's options are:
@@ -301,7 +307,7 @@ Finally run `make install` for installing the module
301307

302308
### For Running Test Cases
303309

304-
Run `sudo cpan Test::Nginx` for installing nginx test module
310+
Install [Test::Nginx](https://github.com/openresty/test-nginx) module for running test cases
305311

306312
Finally run `make test` for running the test cases
307313

0 commit comments

Comments
 (0)