Skip to content

Commit

Permalink
docs: update plugin-develop.md (#3862)
Browse files Browse the repository at this point in the history
I still think we should try our best to prevent modifying APISIX itself.

Signed-off-by: spacewander <spacewanderlzx@gmail.com>
  • Loading branch information
spacewander authored Mar 19, 2021
1 parent f3a6c2a commit 1064e2d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 31 deletions.
26 changes: 11 additions & 15 deletions docs/en/latest/plugin-develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,16 @@ Now using `require "apisix.plugins.3rd-party"` will load your plugin, just like
## check dependencies

if you have dependencies on external libraries, check the dependent items. if your plugin needs to use shared memory, it
needs to declare in **apisix/cli/ngx_tpl.lua**, for example :

```nginx
lua_shared_dict plugin-limit-req 10m;
lua_shared_dict plugin-limit-count 10m;
lua_shared_dict prometheus-metrics 10m;
lua_shared_dict plugin-limit-conn 10m;
lua_shared_dict upstream-healthcheck 10m;
lua_shared_dict worker-events 10m;
# for openid-connect plugin
lua_shared_dict discovery 1m; # cache for discovery metadata documents
lua_shared_dict jwks 1m; # cache for JWKs
lua_shared_dict introspection 10m; # cache for JWT verification results
needs to declare via [customizing Nginx configuration](./customize-nginx-configuration.md), for example :

```yaml
# put this in config.yaml:
nginx_config:
http_configuration_snippet: |
# for openid-connect plugin
lua_shared_dict discovery 1m; # cache for discovery metadata documents
lua_shared_dict jwks 1m; # cache for JWKs
lua_shared_dict introspection 10m; # cache for JWT verification results
```

The plugin itself provides the init method. It is convenient for plugins to perform some initialization after
Expand All @@ -91,7 +87,7 @@ the plugin is loaded.
Note : if the dependency of some plugin needs to be initialized when Nginx start, you may need to add logic to the initialization
method "http_init" in the file __apisix/init.lua__, and you may need to add some processing on generated part of Nginx
configuration file in __apisix/cli/ngx_tpl.lua__ file. But it is easy to have an impact on the overall situation according to the
existing plugin mechanism, we do not recommend this unless you have a complete grasp of the code.
existing plugin mechanism, **we do not recommend this unless you have a complete grasp of the code**.

## name and config

Expand Down
27 changes: 11 additions & 16 deletions docs/zh/latest/plugin-develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,23 @@ title: 插件开发

## 检查外部依赖

如果你的插件,涉及到一些外部的依赖和三方库,请首先检查一下依赖项的内容。 如果插件需要用到共享内存,需要在 __apisix/cli/ngx_tpl.lua__
件里面进行申明,例如:

```nginx
lua_shared_dict plugin-limit-req 10m;
lua_shared_dict plugin-limit-count 10m;
lua_shared_dict prometheus-metrics 10m;
lua_shared_dict plugin-limit-conn 10m;
lua_shared_dict upstream-healthcheck 10m;
lua_shared_dict worker-events 10m;
# for openid-connect plugin
lua_shared_dict discovery 1m; # cache for discovery metadata documents
lua_shared_dict jwks 1m; # cache for JWKs
lua_shared_dict introspection 10m; # cache for JWT verification results
如果你的插件,涉及到一些外部的依赖和三方库,请首先检查一下依赖项的内容。 如果插件需要用到共享内存,需要在[自定义 Nginx 配置](./customize-nginx-configuration.md),例如:

```yaml
# put this in config.yaml:
nginx_config:
http_configuration_snippet: |
# for openid-connect plugin
lua_shared_dict discovery 1m; # cache for discovery metadata documents
lua_shared_dict jwks 1m; # cache for JWKs
lua_shared_dict introspection 10m; # cache for JWT verification results
```
插件本身提供了 init 方法。方便插件加载后做初始化动作。
注:如果部分插件的功能实现,需要在 Nginx 初始化启动,则可能需要在 __apisix/init.lua__ 文件的初始化方法 http_init 中添加逻辑,并且
可能需要在 __apisix/cli/ngx_tpl.lua__ 文件中,对 Nginx 配置文件生成的部分,添加一些你需要的处理。但是这样容易对全局产生影响,根据现有的
插件机制,我们不建议这样做,除非你已经对代码完全掌握。
插件机制,**我们不建议这样做,除非你已经对代码完全掌握**
## 插件命名与配置
Expand Down

0 comments on commit 1064e2d

Please sign in to comment.