apache / apisix-go-plugin-runner

Go Plugin Runner for APISIX
https://apisix.apache.org/
Apache License 2.0
167 stars 69 forks source link

request help: control API for go plugin #98

Open 1696228062 opened 1 year ago

1696228062 commented 1 year ago

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

soulbird commented 1 year ago

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

1696228062 commented 1 year ago

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

soulbird commented 1 year ago

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.

oyiadin commented 1 year ago

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.

soulbird commented 1 year ago

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?

oyiadin commented 1 year ago

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 commented 1 year ago

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

soulbird commented 1 year ago

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.