Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ApiToKafkaBill
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
李伟@五瓣科技
ApiToKafkaBill
Commits
180276e9
Commit
180276e9
authored
Jan 29, 2024
by
Your Name
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix timestamp
parent
288aaa27
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
8 deletions
+47
-8
main.go
main.go
+47
-8
No files found.
main.go
View file @
180276e9
...
...
@@ -212,14 +212,17 @@ func batchToQuestDb(done chan interface{}, reqStream chan pbUpstream.TaskContent
select
{
case
task
:=
<-
resStream
:
nanoseconds
:=
int64
(
task
.
TaskFinishTime
)
seconds
:=
nanoseconds
/
1e9
sender
.
Table
(
resTableName
)
.
Symbol
(
"type"
,
fmt
.
Sprintf
(
"%d"
,
task
.
TaskId
))
.
Symbol
(
"uid"
,
fmt
.
Sprintf
(
"%d"
,
task
.
TaskUid
)
)
.
Symbol
(
"uid"
,
task
.
TaskUid
)
.
Symbol
(
"profit_acc"
,
task
.
TaskProfitAccount
)
.
Symbol
(
"worker_acc"
,
task
.
TaskWorkerAccount
)
.
Symbol
(
"result"
,
task
.
TaskResult
)
.
StringColumn
(
"id"
,
task
.
TaskUuid
)
.
TimestampColumn
(
"time"
,
time
.
Unix
Milli
(
int64
(
task
.
TaskFinishTime
)
))
.
TimestampColumn
(
"time"
,
time
.
Unix
(
seconds
,
nanoseconds
%
1e9
))
.
Int64Column
(
"fee"
,
task
.
TaskFee
)
.
Int64Column
(
"workload"
,
int64
(
task
.
TaskWorkload
))
.
Int64Column
(
"out_len"
,
int64
(
task
.
TaskOutLen
))
.
...
...
@@ -232,17 +235,37 @@ func batchToQuestDb(done chan interface{}, reqStream chan pbUpstream.TaskContent
}
case
task
:=
<-
reqStream
:
// sender.
// Table(reqTableName).
// Symbol("type", fmt.Sprintf("%d", randomType())).
// Symbol("uid", fmt.Sprintf("%d", randomUID())).
// StringColumn("id", uuid.New().String()).
// TimestampColumn("time", time.Now()).
// Int64Column("fee", int64(randomFeeAndWorkload())).
// Int64Column("in_len", int64(randomInput())).
// AtNow(ctx)
_
=
task
taskFeeAsInt
,
err
:=
strconv
.
Atoi
(
task
.
TaskFee
)
if
err
!=
nil
{
fmt
.
Printf
(
"task.TaskFee string to int error: %v
\n
"
,
err
)
continue
}
sender
.
Table
(
reqTableName
)
.
nanoseconds
:=
int64
(
task
.
TaskTimestamp
)
seconds
:=
nanoseconds
/
1e9
// 使用Unix函数转换为time.Time
// t := time.Unix(seconds, nanoseconds%1e9)
// time.Unix()
sender
.
Table
(
reqTableName
)
.
Symbol
(
"type"
,
fmt
.
Sprintf
(
"%d"
,
task
.
TaskType
))
.
Symbol
(
"uid"
,
fmt
.
Sprintf
(
"%d"
,
task
.
TaskUid
)
)
.
Symbol
(
"uid"
,
task
.
TaskUid
)
.
StringColumn
(
"id"
,
task
.
TaskUuid
)
.
TimestampColumn
(
"time"
,
time
.
Unix
Milli
(
int64
(
task
.
TaskTimestamp
)
))
.
TimestampColumn
(
"time"
,
time
.
Unix
(
seconds
,
nanoseconds
%
1e9
))
.
Int64Column
(
"fee"
,
int64
(
taskFeeAsInt
))
.
Int64Column
(
"in_len"
,
int64
(
task
.
TaskInLen
))
.
AtNow
(
ctx
)
...
...
@@ -260,6 +283,22 @@ func batchToQuestDb(done chan interface{}, reqStream chan pbUpstream.TaskContent
}
}
func
randomInput
()
int
{
return
rand
.
Intn
(
1536
)
}
func
randomUID
()
int
{
return
rand
.
Intn
(
10000
)
}
func
randomFeeAndWorkload
()
int
{
return
rand
.
Intn
(
100
)
}
func
randomType
()
int
{
return
rand
.
Intn
(
50
)
}
type
ResponseJson
struct
{
TaskUUID
string
TaskResult
[]
byte
...
...
@@ -361,7 +400,6 @@ func main() {
}
var
cmd
string
var
fee
int64
cmd
=
task
.
Cmd
pbMsg
:=
pbUpstream
.
TaskContent
{
...
...
@@ -370,10 +408,11 @@ func main() {
TaskType
:
1
,
TaskCmd
:
cmd
,
TaskParam
:
[]
byte
(
reqHeaders
[
"Task-Id"
][
0
]),
TaskTimestamp
:
uint64
(
time
.
Now
()
.
Unix
Milli
()),
TaskTimestamp
:
uint64
(
time
.
Now
()
.
Unix
Nano
()),
TaskCallback
:
"http://192.168.1.220:6000/v1/callback"
,
TaskUid
:
reqHeaders
[
"X-Consumer-Custom-Id"
][
0
],
TaskFee
:
fmt
.
Sprintf
(
"%d"
,
fee
),
TaskFee
:
fmt
.
Sprintf
(
"%d"
,
task
.
Price
),
TaskInLen
:
int32
(
len
(
c
.
Body
())),
}
msgAsJson
,
err
:=
json
.
Marshal
(
pbMsg
)
...
...
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