Giter Site home page Giter Site logo

resty-skynet-rpc's Introduction

Name

resty-skynet-rpc - Lua skynet rpc driver for the ngx_lua based on the cosocket API

Table of Contents

Status

This library is on dev.

Description

This Lua library is a skynet rpc driver for the ngx_lua nginx module:

https://github.com/openresty/lua-nginx-module/#readme

This Lua library takes advantage of ngx_lua's cosocket API, which ensures 100% nonblocking behavior.

Note that at least ngx_lua 0.5.14 or OpenResty 1.2.1.14 is required.

Synopsis

    # you do not need the following line if you are using
    # the OpenResty bundle:
    lua_package_path "/path/to/lua-resty-redis/lib/?.lua;;";
    server {				 
        location /test {
            content_by_lua_block {
						local rpc = require "resty.skynet_rpc"
            local r= rpc.new()	
						r:set_timeout(1000)
						r:connect("127.0.0.1",2528)
						local v = r:call("SIMPLEDB","GET","a")
            ngx.say(v)
						r:set_keepalive(5000)

          }
     }

Back to TOC

Methods

Back to TOC

new

syntax: r, err = rpc:new()

Creates a rpc object. In case of failures, returns nil and a string describing the error.

Back to TOC

connect

syntax: ok, err = r:connect(host, port, options_table?)

Attempts to connect to the remote host and port that the skynet server is listened by the skynet server .

Before actually resolving the host name and connecting to the remote backend, this method will always look up the connection pool for matched idle connections created by previous calls of this method.

Back to TOC

set_timeout

syntax: r:set_timeout(time)

Sets the timeout (in ms) protection for subsequent operations, including the connect method.

Back to TOC

set_keepalive

syntax: ok, err = r:set_keepalive(max_idle_timeout, pool_size)

Puts the current connection immediately into the ngx_lua cosocket connection pool.

You can specify the max idle timeout (in ms) when the connection is in the pool and the maximal size of the pool every nginx worker process.

In case of success, returns 1. In case of errors, returns nil with a string describing the error.

Only call this method in the place you would have called the close method instead. Calling this method will immediately turn the current redis object into the closed state. Any subsequent operations other than connect() on the current object will return the closed error.

Back to TOC

close

syntax: ok, err = r:close()

Closes the current rpc connection and returns the status.

In case of success, returns 1. In case of errors, returns nil with a string describing the error.

Back to TOC

call

syntax: r:call(service_name,method,...)

service_name:skynet service name

method:skynet service method fro rpc

...:paras for the skynet service method,cannot be point and function,it cannot be serialize

Back to TOC

Back to TOC

Installation

1.install skynet first: https://github.com/cloudwu/skynet

2.configue skynet cluster:https://github.com/cloudwu/skynet/wiki/Cluster

3.cd lualib-src && make cluster.so

4.copy resty/skynet_rpc.lua and cluster.so to openresty lib

Back to TOC

TODO

Back to TOC

Community

Back to TOC

English Mailing List

Back to TOC

Chinese Mailing List

Back to TOC

Bugs and Patches

Back to TOC

Author

yaoxinming

Back to TOC

Copyright and License

Back to TOC

See Also

Back to TOC

resty-skynet-rpc's People

Stargazers

Ikobe Han avatar ryan avatar libz avatar  avatar QRbaba avatar 菜菜 avatar holder avatar 涵曦 avatar N01ch1v3 avatar shark99 avatar Pengju Y avatar Sanjiang.Liu avatar EverDing avatar guisheng zhou avatar MarkYin avatar zhanglei avatar Yufu Zhao avatar 莫小七 avatar  avatar kwanhur avatar Changwei Hu avatar Heyward Fann avatar saymoon avatar JeOam avatar slightun avatar

Watchers

 avatar MarkYin avatar holder avatar zhang avatar  avatar  avatar

resty-skynet-rpc's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.