Commit 3dd36fce by huangchengyi

1.0

parent ca999a81
Showing with 47 additions and 19 deletions
package main
import (
"flag"
"context"
"kaopu-server/internal/service"
"flag"
"fmt"
"github.com/bilibili/kratos/pkg/conf/paladin"
"kaopu-server/internal/logic"
"kaopu-server/internal/dao"
"fmt"
"kaopu-server/internal/logic"
"kaopu-server/internal/service"
"os"
"strconv"
"sync"
"github.com/ichunt2019/go-msgserver/utils/rabbitmq"
"time"
)
type RecvPro struct {}
func main() {
//获取输入参数s
......@@ -37,29 +40,54 @@ func main() {
svc.DongRun(ctx,mod,""); //运行main
}else{
var wg sync.WaitGroup
for k,_ := range model_dong{
// 开启协程
wg.Add(1)
go func(k int,ctx context.Context,mod_name string,mod_name_log string) {
fmt.Println("--开始协程:"+strconv.Itoa(k))
logic.Loginfo("统计开始--"+mod_name,mod_name_log);
mod_name := dao.Model_dong[k]
mod_name_log :=dao.Model_dong_log[k]
svc := service.New()
svc.DongRun(ctx,mod,""); //运行main
fmt.Println("统计开始:"+strconv.Itoa(k))
logic.Loginfo("统计开始--"+mod_name,mod_name_log);
fmt.Println("--结束协程:"+strconv.Itoa(k))
logic.Loginfo("统计结束--"+mod_name,mod_name_log);
svc := service.New()
svc.DongRun(ctx,mod,""); //运行main
defer wg.Add(-1)
}(k,ctx,dao.Model_dong[k],dao.Model_dong_log[k])
fmt.Println("统计结束:"+strconv.Itoa(k))
logic.Loginfo("统计结束--"+mod_name,mod_name_log);
}
wg.Wait()
fmt.Println("\r\n所有任务已经完成")
}
}
//队列监听
func queues() {
t := &RecvPro{}
queueExchange := &rabbitmq.QueueExchange{
"fengkong_dong_count",
"fengkong_dong_count",
"b_test_rabbit_mq",
"direct",
"amqp://guest:guest@192.168.2.232:5672/",
}
for{
mq := rabbitmq.New(queueExchange)
mq.RegisterReceiver(t)
err :=mq.Start()
if err != nil{
fmt.Println(err)
}
time.Sleep(time.Second)
}
}
//// 实现消费者 消费消息失败 自动进入延时尝试 尝试3次之后入库db
func (t *RecvPro) Consumer(dataByte []byte) error {
fmt.Println(string(dataByte))
//return errors.New("顶顶顶顶")
return nil
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment