Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

官方没出 egg-ratelimit 吗 #3382

Closed
musicode opened this issue Jan 9, 2019 · 8 comments
Closed

官方没出 egg-ratelimit 吗 #3382

musicode opened this issue Jan 9, 2019 · 8 comments

Comments

@musicode
Copy link

musicode commented Jan 9, 2019

我找了一些第三方的库,包括死马写的,都不是很合适,为啥都不支持内存存储呢?

我的需求很简单,大概就以下几个:

  1. 内存存储
  2. 可配置 ip 或别的字段(比如 session id)进行限制
  3. 可配置接口的调用频率,比如 a 接口一分钟几次,b 接口一分钟几次

不是很理解为啥官方为啥没出这个库,难道这个需求不常见吗

@atian25
Copy link
Member

atian25 commented Jan 9, 2019

内存存储没意义啊,多进程和集群情况下又不能共享。
有需要就自己写吧。

@musicode
Copy link
Author

musicode commented Jan 9, 2019

需求2 3,egg 有推荐的库吗

@atian25
Copy link
Member

atian25 commented Jan 9, 2019

可以看下 Koa 社区有没有类似的库,直接引入即可。
其实无非就是加个 Middleware 统计访问次数,然后根据一定的规则来限制而已,可以自己写的。

@musicode
Copy link
Author

musicode commented Jan 9, 2019

ratelimit 这个库需要实例话一个 redis,egg-redis 本身有一个实例,这里又新建一个,感觉不是很好...

@whxaxes
Copy link
Member

whxaxes commented Jan 9, 2019

@musicode 你直接把 egg-redis 里的实例传进去不就行了

@popomore
Copy link
Member

popomore commented Jan 9, 2019

看看能否基于这个扩展 https://github.com/eggjs/egg-guardian

@ZQun
Copy link

ZQun commented Jan 9, 2019

@atian25 atian25 closed this as completed Jan 11, 2019
@windmemory
Copy link

https://github.com/ZQun/egg-ratelimiter 基于ratelimiter

这个东西我试了,没用明白。。。有人提issue,也没人理。。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants