From 85f9e625901c0d0382d1429b1cd17daeb2cbbf1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Thu, 7 Jul 2022 10:31:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20consumer=20=E5=92=8C=20han?= =?UTF-8?q?dler=E6=8E=A5=E5=8F=A3=E7=BA=A6=E6=9D=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- delay/abstract.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/delay/abstract.go b/delay/abstract.go index 842c641..d491388 100644 --- a/delay/abstract.go +++ b/delay/abstract.go @@ -9,6 +9,8 @@ package delay import ( "context" + + "github.com/go-redis/redis/v8" ) // IProduce 生产者约束 @@ -20,3 +22,25 @@ type IProduce interface { // Produce 生产数据 Produce(ctx context.Context, data ...*Queue) error } + +// IConsumer 消费者接口约束 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 10:19 2022/7/7 +type IConsumer interface { + // Consume 消费数据 + Consume(queueName string) ([]*redis.Z, error) + // ConsumeWithHandler 消费数据并使用handler处理 + ConsumeWithHandler(queueName string, handler IHandler) error +} + +// IHandler 消息的处理 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 10:26 2022/7/7 +type IHandler interface { + // Handle 处理消费到的数据 + Handle(queData []*ProduceData) error +}