Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
multisend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李伟@五瓣科技
multisend
Commits
94a698f6
Commit
94a698f6
authored
Mar 01, 2022
by
李伟@五瓣科技
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
print Sending batchTxs to redis
parent
36f9fd66
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
7 deletions
+9
-7
redis.go
redis.go
+9
-7
No files found.
redis.go
View file @
94a698f6
...
...
@@ -8,12 +8,15 @@ import (
"runtime"
"time"
"code.wuban.net.cn/multisend/internal/logging"
"github.com/go-redis/redis/v8"
"golang.org/x/time/rate"
)
var
(
jobnum
=
runtime
.
NumCPU
()
loggerRedis
=
logging
.
NewLogrusLogger
(
"redis"
)
)
type
Job
struct
{
...
...
@@ -46,15 +49,12 @@ func Start(redisAddr, passwd string) {
limiter
:=
rate
.
NewLimiter
(
rate
.
Every
(
time
.
Millisecond
*
100
),
1
)
cxt
,
_
:=
context
.
WithCancel
(
context
.
TODO
())
logTicker
:=
time
.
NewTicker
(
5
*
time
.
Second
)
for
{
limiter
.
Wait
(
cxt
)
select
{
case
batchTxs
:=
<-
batchTxsForRedis
:
//startTime := time.Now()
// data, err := proto.Marshal(txs)
// if err != nil {
// panic(err)
// }
batchTxsAsBytes
,
err
:=
json
.
Marshal
(
batchTxs
)
...
...
@@ -65,9 +65,11 @@ func Start(redisAddr, passwd string) {
if
err
:=
client
.
LPush
(
context
.
Background
(),
"list"
,
batchTxsAsBytes
)
.
Err
();
err
!=
nil
{
panic
(
err
)
}
count
+=
1
//fmt.Printf("count %d txs size: %d takes %v time: %s \n", count, len(batchTxsAsBytes), time.Since(startTime), time.Now())
case
<-
logTicker
.
C
:
loggerRedis
.
Info
(
"Sending batchTxs to redis"
,
"idx"
,
count
,
"toRedis"
,
redisAddr
,
"totaltxsCount"
,
batchTxSize
*
count
,
"now"
,
time
.
Now
()
.
Format
(
"15:04:05"
))
}
}
}
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