Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
孙龙
/
go-api-behavior
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
f0dce6d6
authored
Mar 24, 2020
by
孙龙
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
init
parent
b548381f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
6 deletions
service/behavior/apiMsgService/LogSink.go
service/behavior/main.go
service/behavior/apiMsgService/LogSink.go
View file @
f0dce6d6
package
apiMsgService
import
(
"fmt"
"go-api-behavior/util"
"context"
//"fmt"
"go.mongodb.org/mongo-driver/mongo"
"context"
"go.mongodb.org/mongo-driver/mongo/options"
"time"
)
...
...
@@ -57,7 +56,7 @@ func (logSink *LogSink) writeLoop() {
for
{
select
{
case
log
=
<-
logSink
.
logChan
:
fmt
.
Println
(
"新任务"
)
//
fmt.Println("新任务")
if
logBatch
==
nil
{
logBatch
=
&
LogBatch
{}
}
...
...
@@ -75,8 +74,8 @@ func (logSink *LogSink) writeLoop() {
if
logBatch
==
nil
{
logBatch
=
&
LogBatch
{}
}
fmt
.
Println
(
"超时到期了"
)
fmt
.
Println
(
len
(
logBatch
.
Logs
))
//
fmt.Println("超时到期了")
//
fmt.Println(len(logBatch.Logs))
logSink
.
saveLogs
(
logBatch
)
logBatch
=
nil
t
.
Reset
(
time
.
Second
*
20
)
...
...
service/behavior/main.go
View file @
f0dce6d6
...
...
@@ -17,7 +17,7 @@ type RecvPro struct {
//// 实现消费者 消费消息失败 自动进入延时尝试 尝试3次之后入库db
func
(
t
*
RecvPro
)
Consumer
(
dataByte
[]
byte
)
error
{
fmt
.
Println
(
string
(
dataByte
))
//
fmt.Println(string(dataByte))
err
:=
apiMsgService
.
SaveMsgToLogChan
(
string
(
dataByte
))
if
err
!=
nil
{
logger
.
Error
(
"%s"
,
err
)
...
...
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