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
5d23461f
Commit
5d23461f
authored
Jan 19, 2024
by
Your Name
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bill and kafuka
parent
34a3d3fb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
28 deletions
+55
-28
bill.go
bill.go
+1
-1
main.go
main.go
+54
-27
No files found.
bill.go
View file @
5d23461f
...
...
@@ -103,7 +103,7 @@ func NewMeteringClient(opts ...MeteringOption) *Metering {
Protocol
:
3
,
// specify 2 for RESP 2 or 3 for RESP 3
}),
},
IntervalSeconds
:
1
*
time
.
S
econd
,
IntervalSeconds
:
1
*
time
.
Millis
econd
,
BatchSize
:
BatchSize
,
msgs
:
make
(
chan
BillReq
,
BatchSize
),
quit
:
make
(
chan
struct
{}),
...
...
main.go
View file @
5d23461f
...
...
@@ -337,11 +337,6 @@ func main() {
Bytes
:
pbBytes
,
HttpHeader
:
reqHeaders
,
}
return
c
.
SendStatus
(
200
)
}
else
{
return
c
.
SendString
(
"your balance can not pay the request fee"
)
}
wait
:=
req
(
pbMsg
.
TaskId
)
resAsPb
:=
<-
wait
...
...
@@ -354,6 +349,11 @@ func main() {
}
return
c
.
JSON
(
resAsJson
)
//return c.SendStatus(200)
}
else
{
return
c
.
SendString
(
"your balance can not pay the request fee"
)
}
//return c.SendString("Message sent to Kafka producer.")
})
...
...
@@ -389,20 +389,17 @@ func main() {
return
c
.
SendString
(
fmt
.
Sprintf
(
"pb error: %v"
,
err
.
Error
()))
}
// res := make([]byte, 0, len(prefix)+len(reqHeaders["Task-Id"])+len(body))
// res = append(res, []byte(prefix)...)
// res = append(res, reqHeaders["Task-Id"]...)
// res = append(res, body...
)
accept
:=
Bill
.
Meter
(
UserFee
{
User
:
reqHeaders
[
"X-Consumer-Custom-Id"
],
Fee
:
decimal
.
NewFromInt
(
ChatCompletionsFee
),
}
)
if
accept
{
producerMessagesBytes
<-
bytesAndHeader
{
Bytes
:
pbBytes
,
HttpHeader
:
reqHeaders
,
}
return
c
.
SendStatus
(
200
)
return
c
.
SendStatus
(
200
)
wait
:=
req
(
pbMsg
.
TaskId
)
resAsPb
:=
<-
wait
...
...
@@ -414,6 +411,36 @@ func main() {
}
return
c
.
JSON
(
resAsJson
)
//return c.SendStatus(200)
}
else
{
return
c
.
SendString
(
"your balance can not pay the request fee"
)
}
// res := make([]byte, 0, len(prefix)+len(reqHeaders["Task-Id"])+len(body))
// res = append(res, []byte(prefix)...)
// res = append(res, reqHeaders["Task-Id"]...)
// res = append(res, body...)
// producerMessagesBytes <- bytesAndHeader{
// Bytes: pbBytes,
// HttpHeader: reqHeaders,
// }
// return c.SendStatus(200)
// return c.SendStatus(200)
// wait := req(pbMsg.TaskId)
// resAsPb := <-wait
// resAsJson := ResponseJson{
// TaskId: resAsPb.TaskId,
// TaskResult: resAsPb.TaskResult,
// TaskUid: resAsPb.TaskUid,
// TaskFee: resAsPb.TaskFee,
// }
// return c.JSON(resAsJson)
//return c.SendStatus(200)
//return c.SendString("Message sent to Kafka producer.")
...
...
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