{"id":37327908,"url":"https://github.com/mix-basic/delayer","last_synced_at":"2026-01-16T03:32:39.155Z","repository":{"id":57564061,"uuid":"152033391","full_name":"mix-basic/delayer","owner":"mix-basic","description":"🌶️ 基于 Redis 的延迟队列中间件，采用 Golang 开发，支持 PHP、Golang 等多种语言客户端","archived":false,"fork":false,"pushed_at":"2019-06-13T12:28:31.000Z","size":98,"stargazers_count":191,"open_issues_count":0,"forks_count":27,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-06-20T14:22:38.545Z","etag":null,"topics":["delay","golang","php","queue","redis"],"latest_commit_sha":null,"homepage":"https://openmix.org/mix-basic","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mix-basic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-08T07:04:13.000Z","updated_at":"2024-06-20T02:25:12.000Z","dependencies_parsed_at":"2022-09-16T13:46:02.130Z","dependency_job_id":null,"html_url":"https://github.com/mix-basic/delayer","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/mix-basic/delayer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mix-basic%2Fdelayer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mix-basic%2Fdelayer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mix-basic%2Fdelayer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mix-basic%2Fdelayer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mix-basic","download_url":"https://codeload.github.com/mix-basic/delayer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mix-basic%2Fdelayer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28477204,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T03:13:13.607Z","status":"ssl_error","status_checked_at":"2026-01-16T03:11:47.863Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["delay","golang","php","queue","redis"],"created_at":"2026-01-16T03:32:38.633Z","updated_at":"2026-01-16T03:32:39.139Z","avatar_url":"https://github.com/mix-basic.png","language":"Go","readme":"# Delayer\n\n基于 Redis 的延迟消息队列中间件，采用 Golang 开发，支持 PHP、Golang 等多种语言客户端。\n\n参考 [有赞延迟队列设计](http://tech.youzan.com/queuing_delay) 中的部分设计，优化后实现。\n\n## 应用场景\n\n- 订单超过30分钟未支付，自动关闭订单。\n- 订单完成后, 如果用户一直未评价, 5天后自动好评。\n- 会员到期前3天，短信通知续费。\n- 其他针对某个任务，延迟执行功能的需求。\n\n## 实现原理\n\n- 客户端：push 任务时，任务数据存入 hash 中，jobID 存入 zset 中，pop 时从指定的 list 中取准备好的数据。\n- 服务器端：定时使用连接池并行将 zset 中到期的 jobID 放入对应的 list 中，供客户端 pop 取出。\n\n## 核心特征\n\n- 使用 Golang 开发，高性能。\n- 高可用：服务器端操作是原子的，并且做了优雅停止，不会丢失数据，在redis断线时会自动重连。\n- 可通过配置文件控制执行性能参数。\n- 提供多种语言的 SDK，使用简单快捷。\n\n## 如何使用\n\n`delayer` 分为：\n\n- 服务器端：负责定时扫描到期的任务，并放入队列，需在服务器上常驻执行。\n- 客户端：在代码中使用，以类库的形式，提供 `push`、`pop`、`bPop`、`remove` 方法操作任务。\n\n## 服务器端\n\n在 https://github.com/mix-basic/delayer/releases 中下载对应平台的程序。\n\n\u003e 支持 windows、linux、mac 三种平台\n\n然后修改配置文件 `delayer.conf`：\n\n```\n[delayer]\npid = /var/run/delayer.pid      ; 需单例执行时配置, 多实例执行时留空, Win不支持单例\ntimer_interval = 1000           ; 计算间隔时间, 单位毫秒\naccess_log = logs/access.log    ; 存取日志\nerror_log = logs/error.log      ; 错误日志\n\n[redis]\nhost = 127.0.0.1                ; 连接地址\nport = 6379                     ; 连接端口\ndatabase = 0                    ; 数据库编号\npassword =                      ; 密码, 无需密码留空\nmax_idle = 2                    ; 最大空闲连接数\nmax_active = 20                 ; 最大激活连接数\nidle_timeout = 3600             ; 空闲连接超时时间, 单位秒\nconn_max_lifetime = 3600        ; 连接最大生存时间, 单位秒\n```\n\n查看帮助：\n\n```\n[root@localhost bin]# ./delayer -h\nUsage: delayer [options]\n\nOptions:\n-d/--daemon run in the background\n-c/--configuration FILENAME -- configuration file path (searches if not given)\n-h/--help -- print this usage message and exit\n-v/--version -- print version number and exit\n```\n\n启动：\n\n```\n[root@localhost bin]# ./delayer\n    ____       __\n   / __ \\___  / /___ ___  _____  _____\n  / / / / _ \\/ / __ `/ / / / _ \\/ ___/\n / /_/ /  __/ / /_/ / /_/ /  __/ /\n/_____/\\___/_/\\__,_/\\__, /\\___/_/\n                   /____/\nService:\t\tdelayer\nVersion:\t\t1.0.1\n[info] 2018/10/21 11:24:24 Service started successfully, PID: 31023\n```\n\n## 客户端\n\n我们提供了以下几种语言：\n\n\u003e 根据对应项目的说明使用\n\n- PHP：https://github.com/mix-basic/delayer-client-php\n- Golang：https://github.com/mix-basic/delayer-client-golang\n- Java：待定\n- Python：待定\n\n## License\n\nApache License Version 2.0, http://www.apache.org/licenses/\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmix-basic%2Fdelayer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmix-basic%2Fdelayer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmix-basic%2Fdelayer/lists"}