You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by sp...@apache.org on 2022/03/01 14:05:37 UTC
[apisix] branch master updated: refactor(grpc-transcode): new way to handle pb file (#6467)
This is an automated email from the ASF dual-hosted git repository.
spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new a7bde90 refactor(grpc-transcode): new way to handle pb file (#6467)
a7bde90 is described below
commit a7bde90d9a492fe88f94f20ca0b405311299090d
Author: 罗泽轩 <sp...@gmail.com>
AuthorDate: Tue Mar 1 22:05:27 2022 +0800
refactor(grpc-transcode): new way to handle pb file (#6467)
---
apisix/plugins/grpc-transcode/proto.lua | 16 +++++++++-------
rockspec/apisix-master-0.rockspec | 2 +-
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/apisix/plugins/grpc-transcode/proto.lua b/apisix/plugins/grpc-transcode/proto.lua
index e997b55..c30c17e 100644
--- a/apisix/plugins/grpc-transcode/proto.lua
+++ b/apisix/plugins/grpc-transcode/proto.lua
@@ -77,20 +77,22 @@ local function compile_proto_bin(content)
return nil
end
+ local files = pb.decode("google.protobuf.FileDescriptorSet", content).file
local index = {}
- for name, _, methods in pb.services() do
- local method_index = {}
- for _, m in ipairs(methods) do
- method_index[m.name] = m
+ for _, f in ipairs(files) do
+ for _, s in ipairs(f.service or {}) do
+ local method_index = {}
+ for _, m in ipairs(s.method) do
+ method_index[m.name] = m
+ end
+
+ index[f.package .. '.' .. s.name] = method_index
end
- -- remove the prefix '.'
- index[name:sub(2)] = method_index
end
local compiled = {}
compiled[proto_fake_file] = {}
compiled[proto_fake_file].index = index
-
return compiled
end
diff --git a/rockspec/apisix-master-0.rockspec b/rockspec/apisix-master-0.rockspec
index ae12950..55f06b4 100644
--- a/rockspec/apisix-master-0.rockspec
+++ b/rockspec/apisix-master-0.rockspec
@@ -46,7 +46,7 @@ dependencies = {
"lua-resty-session = 2.24",
"opentracing-openresty = 0.1",
"lua-resty-radixtree = 2.8.1",
- "api7-lua-protobuf = 0.1.0",
+ "lua-protobuf = 0.3.4",
"lua-resty-openidc = 1.7.2-1",
"luafilesystem = 1.7.0-2",
"api7-lua-tinyyaml = 0.4.2",