Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
孙龙
/
kaopu-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3dd36fce
authored
Dec 05, 2019
by
huangchengyi
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
1.0
parent
ca999a81
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
19 deletions
cmd/dong/main.go
cmd/dong/main.go
View file @
3dd36fce
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
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment