增加 consumer 和 handler接口约束
This commit is contained in:
		| @ -9,6 +9,8 @@ package delay | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"context" | 	"context" | ||||||
|  |  | ||||||
|  | 	"github.com/go-redis/redis/v8" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| // IProduce 生产者约束 | // IProduce 生产者约束 | ||||||
| @ -20,3 +22,25 @@ type IProduce interface { | |||||||
| 	// Produce 生产数据 | 	// Produce 生产数据 | ||||||
| 	Produce(ctx context.Context, data ...*Queue) error | 	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 | ||||||
|  | } | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user