Note that the config run after filter will be different from the raw
input. So if dump is enabled, we should create a copy of the original
data and dump this one.
https://github.com/apache/apisix/blob/cd4d2ece58a1075545d3a2dc929b014049f53f21/apisix/upstream.lua#L470

聂永 <[email protected]> 于2021年4月14日周三 下午5:46写道:
>
> Hi,
>
> We need the `etcd` cluster for storing gateway's config, but we are afraid of 
>  it being inaccessible when we reload or deploy gateway distance as network 
> issues.
>
> ## Dump etcd
>
> So, we need the apisix to dump the etcd's stored data into `conf/apisix.yaml 
> ` file, when it is running every 5 minutes.
>
> And, if the already existed apisix distance need to restart in some 
> unexpected case, or we need do deploy a large number of distance online in a 
> short time, if the distance queries data from `etcd` unsuccessfully when 
> starting, we need to load the dumped `conf/apisix.yaml` file into memory once.
>
> Firstly, we need to import the `dump` for `etcd` config:
>
> ```yaml
> etcd:
>   host:
>     - "http://172.19.5.10:23792";
>   prefix: "/apisix"
>   dump:
>     interval: 300                   # unit seconds
>     load_on_failure: true         # if true, then try to load data from 
> dumped conf/apisix.yaml file when querying etcd failure first
> ```
>
> And, when initializing, it will start a timer for dumping in cycles:
>
> ```lua
>     local dump_conf = etcd_conf.dump
>     local dump_interval = dump_conf.interval or 300
>
>     if dump_interval > 0 and 0 == ngx.worker.id() then
>         ngx_timer_every(dump_interval, dump_etcd)
>     end
> ```
>
> If it queries `etcd` failure first time, then will try to load data from 
> `conf/apisix.yaml` file once,(with its work flow pic 
> https://user-images.githubusercontent.com/548385/114687020-e8dc7b80-9d45-11eb-94ea-1f28465e0580.png),
>  and its code snippet below:
>
> ```lua
>             local ok, err = sync_data(self)
>             if err then
>                 if i == 1 and self.fail_load_yaml and not 
> failure_map[self.key] then
>                     failure_map[self.key] = 1
>                     try_load_data_from_yaml(self)
>                 end
>
>                 ......
> ```
>
> ## More usage
>
> If we use  [`Stand-alone 
> mode`](https://github.com/apache/apisix/blob/master/docs/en/latest/stand-alone.md)
>  below:
>
> ```yaml
> config_center: yaml
> ```
>
> We can also use it to update `conf/apisix.yaml` file periodically.
>
>
>
>

Reply via email to