You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apisix.apache.org by "88786912@qq.com" <88...@qq.com> on 2020/04/13 04:24:47 UTC

[help] how to solve the plugin's complex schema?

Hi,
I want to develop a new  APISIX plug-in for my scenario, but it's schema is more complex, the recommended way is to split it into multiple plug-ins or to keep one?
I want to get it form the schema file instead of initializing the table in it's file if recommend the latter.
Is there anything wrong or some risk in this way.

```
local prefix = ngx.config.prefix()
    local plugin_xsd_file = prefix .. "/conf/plugin.schema.json"
    local f = assert(io.open(cfg_file))
    local xsd_t = json.decode(assert(f:read('*a')))
    f:close()
    --local myvalidator = jsonschema.generate_validator(xsd_t)
```

thx~


88786912@qq.com

Re: [help] how to solve the plugin's complex schema?

Posted by Ming Wen <we...@apache.org>.
Hello,
I don't know how complicated your plugin is, maybe you can say it more
clearly.

We recommend that one plugin only do one thing, and multiple plugins can be
used together.

I don't think it's a good idea to read the schema from a local file.
First it will affect performance, and secondly it will cause difficulties
in code management and maintenance.

Thanks,
Ming Wen, Apache APISIX & Apache SkyWalking
Twitter: _WenMing


88786912@qq.com <88...@qq.com> 于2020年4月13日周一 下午12:25写道:

> Hi,
> I want to develop a new  APISIX plug-in for my scenario, but it's schema
> is more complex, the recommended way is to split it into multiple plug-ins
> or to keep one?
> I want to get it form the schema file instead of initializing the table in
> it's file if recommend the latter.
> Is there anything wrong or some risk in this way.
>
> ```
> local prefix = ngx.config.prefix()
>     local plugin_xsd_file = prefix .. "/conf/plugin.schema.json"
>     local f = assert(io.open(cfg_file))
>     local xsd_t = json.decode(assert(f:read('*a')))
>     f:close()
>     --local myvalidator = jsonschema.generate_validator(xsd_t)
> ```
>
> thx~
>
>
> 88786912@qq.com
>

Re: [help] how to solve the plugin's complex schema?

Posted by YuanSheng Wang <me...@apache.org>.
>     local plugin_xsd_file = prefix .. "/conf/plugin.schema.json"

I also think that this is not a good method, it will make Apache APISIX can
not easily complete horizontal expansion.
because it also depends on the local configuration file.

On Mon, Apr 13, 2020 at 12:25 PM 88786912@qq.com <88...@qq.com> wrote:

> Hi,
> I want to develop a new  APISIX plug-in for my scenario, but it's schema
> is more complex, the recommended way is to split it into multiple plug-ins
> or to keep one?
> I want to get it form the schema file instead of initializing the table in
> it's file if recommend the latter.
> Is there anything wrong or some risk in this way.
>
> ```
> local prefix = ngx.config.prefix()
>     local plugin_xsd_file = prefix .. "/conf/plugin.schema.json"
>     local f = assert(io.open(cfg_file))
>     local xsd_t = json.decode(assert(f:read('*a')))
>     f:close()
>     --local myvalidator = jsonschema.generate_validator(xsd_t)
> ```
>
> thx~
>
>
> 88786912@qq.com
>


-- 
*MembPhis*
My github: https://github.com/membphis
Apache APISIX: https://github.com/apache/incubator-apisix