apisix-go-plugin-runner icon indicating copy to clipboard operation
apisix-go-plugin-runner copied to clipboard

request help: control API for go plugin

Open 1696228062 opened this issue 2 years ago • 8 comments

Issue description

image What should I do if I want to use the control API in the go plugin? Or is there any other solution to achieve similar functions

Environment

  • APISIX Go Plugin Runner's version:0.3.0
  • APISIX version: 2.14
  • Go version: 1.15
  • OS (cmd: uname -a): linux

1696228062 avatar Aug 02 '22 09:08 1696228062

I can't get your point, do you want to register control api in go runner? Can you describe your use case in detail?

soulbird avatar Aug 02 '22 09:08 soulbird

我在apisix新增了一个自定义的go插件, 我希望这个插件能提供一个对内的api,从而让我的内部脚本可以通过http请求的方式调用,来触发插件内的一些缓存更新的逻辑。 比如, 我的go plugin内有一个全局变量 a int 缓存了一个值为 1 我期望,我能在go plugin内开一个接口, 当此接口被调用,go plugin内的全局变量a 的值变为2

1696228062 avatar Aug 02 '22 11:08 1696228062

You can start an http service in your own go-runner, expose your API, and then create a route in APISIX to protect your API interface.

soulbird avatar Aug 04 '22 00:08 soulbird

I need this feature too ;-)

IMO, though exposing a new http service in the go-runner is a feasible solution, I do think that the APISIX control API is somewhere more suitable.

oyiadin avatar Nov 07 '22 02:11 oyiadin

Do you mean that the control api in APISIX can also take effect in go runner, or use golang alone to support control api in go runner?

soulbird avatar Nov 10 '22 05:11 soulbird

I mean, to register control api like what we can did in lua: https://apisix.apache.org/docs/apisix/plugin-develop/#register-control-api Maybe we should add another RPC event for this purpose.

oyiadin avatar Nov 10 '22 14:11 oyiadin

If we decide to implement this feature, IMO, we should support it in every language that APISIX supports: go, python and java. Not only golang

oyiadin avatar Nov 10 '22 14:11 oyiadin

I mean, to register control api like what we can did in lua: https://apisix.apache.org/docs/apisix/plugin-develop/#register-control-api Maybe we should add another RPC event for this purpose.

If it is to implement the same feature as in Lua, it seems that it can only be supported in go-plugin-runner, and it is not necessary to add an RPC event to interact with APISIX.

soulbird avatar Nov 11 '22 01:11 soulbird