Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Add a method to clear all messages from a channel

未关闭
#306 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
冷清
技术栈
php, rabbitmq, redis

调研方向

先阅读 AdapterInterface 和现有的 push/status 入口,然后检查 Redis、AMQP 和内存适配器。解决 purge 与 clear 的命名问题以及 channel 签名问题;当 opt-in 接口和提议的适配器实现支持清空 channel 且不改变主接口时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

Proposed new feature or change

There's no programmatic way to empty a queue. It comes up in three places:

  1. Maintenance - a queue:purge command or an admin button to drop a queue that got flooded with poison pills or jobs that are no longer wanted.
  2. Deployments - clearing a queue during a release when the payload structure changed and old queued jobs would crash on the new code.
  3. Testing - resetting state between runs. Shelling out to redis-cli or rabbitmqctl makes the test suite fragile and awkward to run in containerized CI.

I wouldn't put this on AdapterInterface - that would break every existing implementation and it overlaps with the "not the job of the primary interface" point from #271. A separate opt-in interface fits better:

interface PurgeableInterface
{
    public function purge(): void;
}

Adapters implement it when the backend can do it cheaply (Redis drops the channel keys, AMQP calls queue_purge, the in-memory adapter resets its array). Callers check for it:

if ($adapter instanceof PurgeableInterface) {
    $adapter->purge();
}

Open questions:

  1. Name: purge() (broker vocabulary) or clear()?
  2. Signature: purge(): void on the adapter's current channel (consistent with push/status, which don't take a channel) or purge(string $channel)?

Worth pursuing? Happy to send a PR if you're good with it (core + redis/amqp).

主要语言
PHP
星标
61
派生
31
平均合并
1 天 7 小时
30 天内合并 PR
9

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

yiisoft/queue 的其他 Issue

查看 yiisoft/queue 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。