diff --git a/ats-tracer/controller.go b/ats-tracer/controller.go index 14dd828..55e5a0a 100644 --- a/ats-tracer/controller.go +++ b/ats-tracer/controller.go @@ -117,17 +117,17 @@ func (c *Controller) traceRange() { }() if c.doTrace(tracer) { - // 如果蹲到了,需要通知 - //resp, err := pusher.Push(c.ctx, &push.PushReq{ - // Title: "coach 断货", - // Content: fmt.Sprintf("coach 商品 %s 断货了\n库存为0\n链接:%s", tracer.pArticle.SkuID, tracer.pArticle.Link), - //}) - //if err != nil { - // glog.Errorf("消息推送失败:%v", err) - //} - //if resp.Code != 0 { - // glog.Errorf("消息推送失败:%s", resp.Msg) - //} + //如果蹲到了,需要通知 + resp, err := pusher.Push(c.ctx, &push.PushReq{ + Title: "coach 断货", + Content: fmt.Sprintf("coach 商品 %s 断货了\n库存为0\n链接:%s", tracer.pArticle.SkuID, tracer.pArticle.Link), + }) + if err != nil { + glog.Errorf("消息推送失败:%v", err) + } + if resp.Code != 0 { + glog.Errorf("消息推送失败:%s", resp.Msg) + } tracer.pArticle.SetTraceAts(false) _ = c.storage.ProviderArticle().Update(*tracer.pArticle, "trace_ats") c.tracers.Remove(tracer.pArticle.SkuID) diff --git a/cmd/main.go b/cmd/main.go index 537ee17..2d50f41 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -16,6 +16,8 @@ import ( "gitea.timerzz.com/kedaya_haitao/common/pkg/proxy" "gitea.timerzz.com/kedaya_haitao/common/pkg/redis" "gitea.timerzz.com/kedaya_haitao/common/pkg/web" + "gitea.timerzz.com/kedaya_haitao/pusher/rpc/pusher" + "github.com/cloudwego/kitex/client" "github.com/gofiber/fiber/v3" "github.com/gofiber/fiber/v3/middleware/cors" "github.com/gofiber/fiber/v3/middleware/recover" @@ -45,7 +47,7 @@ func main() { glog.Fatalf("初始化redis失败:%v", err) } - //pusher.InitClient("pusher", client.WithHostPorts("pusher:8080")) + pusher.InitClient("pusher", client.WithHostPorts("pusher:8080")) // 代理池 pool := proxy.NewProxyPool(cfg.Proxy.Subscribes) diff --git a/watcher/controller.go b/watcher/controller.go index e55cb99..0428e2f 100644 --- a/watcher/controller.go +++ b/watcher/controller.go @@ -10,6 +10,8 @@ import ( coach_client "gitea.timerzz.com/kedaya_haitao/common/pkg/coach-client" "gitea.timerzz.com/kedaya_haitao/common/structs/storage" v2 "gitea.timerzz.com/kedaya_haitao/common/structs/v2" + "gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/push" + "gitea.timerzz.com/kedaya_haitao/pusher/rpc/pusher" "github.com/golang/glog" "gorm.io/gorm" ) @@ -114,17 +116,17 @@ func (c *Controller) watchRange() { }() if c.doWatch(watcher) { - //// 如果蹲到了,需要通知 - //resp, err := pusher.Push(c.ctx, &push.PushReq{ - // Title: "coach 补货", - // Content: fmt.Sprintf("coach 商品 %s 补货\n库存:%d\n链接:%s", watcher.pArticle.SkuID, watcher.pArticle.Ats, watcher.pArticle.Link), - //}) - //if err != nil { - // glog.Errorf("消息推送失败:%v", err) - //} - //if resp.Code != 0 { - // glog.Errorf("消息推送失败:%s", resp.Msg) - //} + // 如果蹲到了,需要通知 + resp, err := pusher.Push(c.ctx, &push.PushReq{ + Title: "coach 补货", + Content: fmt.Sprintf("coach 商品 %s 补货\n库存:%d\n链接:%s", watcher.pArticle.SkuID, watcher.pArticle.Ats, watcher.pArticle.Link), + }) + if err != nil { + glog.Errorf("消息推送失败:%v", err) + } + if resp.Code != 0 { + glog.Errorf("消息推送失败:%s", resp.Msg) + } watcher.pArticle.SetWatch(false) _ = c.storage.ProviderArticle().Update(*watcher.pArticle, "watch") c.watchers.Remove(watcher.pArticle.SkuID)