Skip to content

Commit

Permalink
Merge branch 'feature/grpc-proxy' of github.com:nic-chen/apisix into …
Browse files Browse the repository at this point in the history
…feature/grpc-proxy

# Conflicts:
#	lua/apisix/plugins/grpc-proxy/proto.lua
  • Loading branch information
johzchen committed Aug 19, 2019
2 parents e1fc42e + 05c1007 commit c42ec53
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lua/apisix/admin/routes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ local function check_conf(id, conf, need_id)
return nil, {error_msg = "wrong route id"}
end

core.log.info("schema: ", core.json.delay_encode(core.schema.route))
core.log.info("schema: ", core.schema.route)
core.log.info("conf : ", core.json.delay_encode(conf))
local ok, err = core.schema.check(core.schema.route, conf)
if not ok then
Expand Down
5 changes: 1 addition & 4 deletions lua/apisix/http/router.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function _M.init_worker()
local conf = local_conf()
local router_http_name = "r3_uri"
local router_ssl_name = "r3_sni"

if conf and conf.apisix and conf.apisix.router then
router_http_name = conf.apisix.router.http or router_http_name
router_ssl_name = conf.apisix.router.ssl or router_ssl_name
Expand All @@ -22,10 +23,6 @@ function _M.init_worker()
local router_ssl = require("apisix.http.router." .. router_ssl_name)
router_ssl:init_worker()
_M.router_ssl = router_ssl

local proto = require("apisix.plugins.grpc-proxy.proto")
proto:init_worker()

end


Expand Down
11 changes: 8 additions & 3 deletions lua/apisix/plugins/grpc-proxy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ local schema = {

local _M = {
version = 0.1,
priority = 500,
priority = 506,
name = plugin_name,
schema = schema,
}


function _M.init()
proto.init()
end


function _M.check_schema(conf)
local ok, err = core.schema.check(schema, conf)
if not ok then
Expand All @@ -33,7 +38,7 @@ function _M.access(conf, ctx)
local proto_id = conf.proto_id
if not proto_id then
ngx.log(ngx.ERR, ("proto id miss: %s"):format(proto_id))
return
return
end

local p, err = proto.new(proto_id)
Expand All @@ -60,7 +65,7 @@ function _M.body_filter(conf, ctx)
local proto_id = conf.proto_id
if not proto_id then
ngx.log(ngx.ERR, ("proto id miss: %s"):format(proto_id))
return
return
end

local p, err = proto.new(proto_id)
Expand Down
4 changes: 2 additions & 2 deletions lua/apisix/plugins/grpc-proxy/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ _M.map_message = function(field, default_values)
end

local request = {}
local sub, err
local sub, err
for name, _, field_type in pb.fields(field) do
if field_type:sub(1, 1) == "." then
sub, err = _M.map_message(field_type, default_values)
Expand All @@ -79,4 +79,4 @@ _M.map_message = function(field, default_values)
return request, nil
end

return _M
return _M
2 changes: 1 addition & 1 deletion t/admin/plugins.t
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ __DATA__
--- request
GET /apisix/admin/plugins/list
--- response_body_like eval
qr/\["limit-req","limit-count","limit-conn","key-auth","prometheus","node-status","jwt-auth","zipkin"\]/
qr/\["limit-req","limit-count","limit-conn","key-auth","prometheus","node-status","jwt-auth","zipkin","grpc-proxy"\]/
--- no_error_log
[error]
2 changes: 1 addition & 1 deletion t/admin/schema.t
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ __DATA__
--- request
GET /apisix/admin/schema/route
--- response_body eval
qr/"plugins": \{"type":"object"}/
qr/"plugins":\{"type":"object"}/
--- no_error_log
[error]

Expand Down
1 change: 1 addition & 0 deletions t/debug-mode.t
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ loaded plugin and sort by priority: 1003 name: limit-conn
loaded plugin and sort by priority: 1002 name: limit-count
loaded plugin and sort by priority: 1001 name: limit-req
loaded plugin and sort by priority: 1000 name: node-status
loaded plugin and sort by priority: 506 name: grpc-proxy
loaded plugin and sort by priority: 500 name: prometheus
loaded plugin and sort by priority: 0 name: example-plugin
loaded plugin and sort by priority: -1000 name: zipkin
Expand Down

0 comments on commit c42ec53

Please sign in to comment.