背景 链接到标题 最近读完了 《Redis 实战》对 Redis 有了一些了解,但是没有在实际项目中应用过,就想找一个使用 Redis 的项目来看看,找到 Huey 是因为之前使用过,趁机了解下具体实现。
简介 链接到标题 Huey 的定位是一个轻量级的任务队列,仅依赖于 Redis 作为任务相关信息存储,支持的功能有:
多种 worker 执行方式:thread,process,greenlet 支持多种任务类型:特定时间运行,周期性运行 包含重试机制,可以指定重试次数及重试间隔 支持任务锁 … 我们根据官方的示例,来看看 Huey 是如何处理任务的,目录结构如下:
master ✔ $ pwd /Users/yiran/Documents/git-repo/huey/examples/simple yiran@zhouyirandeMacBook-Pro:~/Documents/git-repo/huey/examples/simple master ✔ $ tree . . ├── README ├── __init__.py ├── config.py ├── cons.sh ├── main.py └── tasks.py 注意,这个目录结构是 Huey 官方建议的,具体原因为:
Behind-the-scenes when you decorate a function with task() or periodic_task(), the function registers itself with a centralized in-memory registry.