|
15 | 15 | -- limitations under the License.
|
16 | 16 | --
|
17 | 17 |
|
| 18 | +--- Get configuration information. |
| 19 | +-- |
| 20 | +-- @module core.config_etcd |
| 21 | + |
18 | 22 | local table = require("apisix.core.table")
|
19 | 23 | local config_local = require("apisix.core.config_local")
|
20 | 24 | local log = require("apisix.core.log")
|
@@ -604,6 +608,28 @@ local function _automatic_fetch(premature, self)
|
604 | 608 | end
|
605 | 609 |
|
606 | 610 |
|
| 611 | +--- |
| 612 | +-- Create a new connection to communicate with the control plane. |
| 613 | +-- This function should be used in the `init_worker_by_lua` phase. |
| 614 | +-- |
| 615 | +-- @function core.config.new |
| 616 | +-- @tparam string etcd directory to be monitored, e.g. "/routes". |
| 617 | +-- @tparam table opts Parameters related to the etcd client connection. |
| 618 | +-- The keys in `opts` are as follows: |
| 619 | +-- * automatic: whether to get the latest etcd data automatically |
| 620 | +-- * item_schema: the jsonschema that checks the value of each item under the **key** directory |
| 621 | +-- * filter: the custom function to filter the value of each item under the **key** directory |
| 622 | +-- * timeout: the timeout for watch operation, default is 30s |
| 623 | +-- * single_item: whether only one item under the **key** directory |
| 624 | +-- * checker: the custom function to check the value of each item under the **key** directory |
| 625 | +-- @treturn table The etcd client connection. |
| 626 | +-- @usage |
| 627 | +-- local plugins_conf, err = core.config.new("/custom_dir", { |
| 628 | +-- automatic = true, |
| 629 | +-- filter = function(item) |
| 630 | +-- -- called once before reload for sync data from admin |
| 631 | +-- end, |
| 632 | +--}) |
607 | 633 | function _M.new(key, opts)
|
608 | 634 | local local_conf, err = config_local.local_conf()
|
609 | 635 | if not local_conf then
|
|
0 commit comments