Skip to content

Latest commit

 

History

History
93 lines (59 loc) · 1.41 KB

README.md

File metadata and controls

93 lines (59 loc) · 1.41 KB

lua-resty-sse

Lua Server Side Events client cosocket driver for OpenResty / ngx_lua.

Status

This library is still under active development and is considered production ready.

API

Synopsis

lua_package_path "/path/to/lua-resty-sse/lib/?.lua;;";

server {


  location /simpleinterface {
    resolver 8.8.8.8;  # Google's open DNS server for an example

    content_by_lua_block {
      local sse = require "resty.sse"

      local conn, err = sse.new()
      if not conn then
        ngx.say("failed to get connection: ", err)
      end

      local res, err = conn:request_uri("http://some-pub-sub-server.com/subscriber")

      if not res then
        ngx.say("failed to request: ", err)
        return
      end

      while true
        local event, err = conn:receive()
        if err then ngx.say("got an error: ", err) end
        if event then  ngx.say("got an event: ", event) end
      end
    }
  }
}

Connection

new

TODO

connect

TODO

set_timeout

TODO

set_keepalive

TODO

get_reused_times

TODO

close

TODO

request

TODO

request_uri

TODO

receive

TODO