老师,限制器的组合小节里面的代码,limit_req重复了,应该有一个limit_count。
课后习题:
local limit_rate = require "resty.limit.rate"
local limit_count = require "resty.limit.count"
local limit_conn = require "resty.limit.conn"
local lim_rate, err = limit_rate.new("my_rate_store", 100, 6000, 2) -- 将resty.limit.req替换成resty.limit.rate即可
local lim_count, err = limit_count.new("my_count_store", 200, 100)
local lim_conn, err = limit_conn.new("my_conn_store", 1000, 1000, 0.5)
local limiters = {lim_rate, lim_count, lim_conn}
local host = ngx.var.host
local client = ngx.var.binary_remote_addr
local keys = {host, client, client}
local delay, err = limit_traffic.combine(limiters, keys, states)
展开