1 Star 0 Fork 0

庞飞/multiapp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
retry.go 1.38 KB
一键复制 编辑 原始数据 按行查看 历史
庞飞 提交于 2023-10-03 10:28 . 合并主框架
package producerconsumer
import (
"github.com/golang/protobuf/ptypes"
message "gitee.com/pangxianfei/multiapp/queue/protocol_buffers"
)
type queueRetry struct {
p producer
paramProtoByte []byte
hash string
}
func newQueryRetry(fq FailedQueuer) *queueRetry {
return &queueRetry{
p: producer{
topicName: fq.RetryTopic(),
channelName: fq.RetryChannel(),
retries: fq.RetryRetries(),
delay: fq.RetryDelay(),
},
paramProtoByte: fq.RetryParamProtoBytes(),
hash: fq.RetryHash(),
}
}
func (r *queueRetry) retry() error {
return push(r.p.topicName, r.p.channelName, &message.Message{
Hash: r.hash,
Param: r.paramProtoByte,
Retries: r.p.retries,
PushedAt: ptypes.TimestampNow(),
Delay: ptypes.DurationProto(r.p.delay),
Tried: 0,
})
}
func Forget(id uint) error {
// delete the retried failed queue
if err := failedProcessor.DeleteQueueById(id); err != nil {
return err
}
return nil
}
func Flush() error {
//@todo to be done
panic("need implements")
}
func Retry(id uint) error {
// find the failed queue
fq, err := failedProcessor.FailedQueueById(id)
if err != nil {
return err
}
// retry the failed queue
if err := newQueryRetry(fq).retry(); err != nil {
return err
}
// delete the retried failed queue
if err := failedProcessor.DeleteQueueById(id); err != nil {
return err
}
return nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/pangxianfei/multiapp.git
git@gitee.com:pangxianfei/multiapp.git
pangxianfei
multiapp
multiapp
v1.2.2

搜索帮助