Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
apaas-meshproxy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gzga-jzapi
apaas-meshproxy
Commits
b4d4ebcc
Commit
b4d4ebcc
authored
Nov 04, 2020
by
leitao.zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调用记录
parent
c91916a4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
21 deletions
+27
-21
src/dao/service_request_record.go
src/dao/service_request_record.go
+14
-12
src/service/field.go
src/service/field.go
+13
-9
No files found.
src/dao/service_request_record.go
View file @
b4d4ebcc
package
dao
package
dao
import
"gitlab.wodcloud.com/apaas/apaas-meshproxy/src/tools"
import
(
"time"
)
type
ServiceRequestRecord
struct
{
type
ServiceRequestRecord
struct
{
Id
int
`json:"id" xorm:"id"`
//
Id int `json:"id" xorm:"id"`
ServiceId
int
`json:"service_id" xorm:"service_id"`
ServiceId
int
`json:"service_id" xorm:"service_id"`
ApplyId
int
`json:"apply_id" xorm:"apply_id"`
ApplyId
int
`json:"apply_id" xorm:"apply_id"`
UserId
string
`json:"user_id" xorm:"user_id"`
UserId
string
`json:"user_id" xorm:"user_id"`
RequestTime
t
ools
.
Json
Time
`json:"request_time" xorm:"request_time created"`
RequestTime
t
ime
.
Time
`json:"request_time" xorm:"request_time created"`
DateDay
int
`json:"date_day" xorm:"date_day"`
DateDay
int
`json:"date_day" xorm:"date_day"`
DateMonth
int
`json:"date_month" xorm:"date_month"`
DateMonth
int
`json:"date_month" xorm:"date_month"`
DateYear
int
`json:"date_year" xorm:"date_year"`
DateYear
int
`json:"date_year" xorm:"date_year"`
...
...
src/service/field.go
View file @
b4d4ebcc
...
@@ -18,7 +18,6 @@ import (
...
@@ -18,7 +18,6 @@ import (
"gitlab.wodcloud.com/apaas/apaas-meshproxy/src/model"
"gitlab.wodcloud.com/apaas/apaas-meshproxy/src/model"
"gitlab.wodcloud.com/apaas/apaas-meshproxy/src/model/request"
"gitlab.wodcloud.com/apaas/apaas-meshproxy/src/model/request"
"gitlab.wodcloud.com/apaas/apaas-meshproxy/src/model/tables"
"gitlab.wodcloud.com/apaas/apaas-meshproxy/src/model/tables"
"gitlab.wodcloud.com/apaas/apaas-meshproxy/src/tools"
"gitlab.wodcloud.com/apaas/apaas-meshproxy/src/tools/dataconvertutil"
"gitlab.wodcloud.com/apaas/apaas-meshproxy/src/tools/dataconvertutil"
"log"
"log"
"time"
"time"
...
@@ -91,7 +90,7 @@ func GetExpire() time.Duration {
...
@@ -91,7 +90,7 @@ func GetExpire() time.Duration {
//记录调用痕迹
//记录调用痕迹
func
RecordCall
(
proxyData
model
.
ProxyData
,
status
int
,
res
[]
byte
)
{
func
RecordCall
(
proxyData
model
.
ProxyData
,
status
int
,
res
[]
byte
)
{
acc
:=
dao
.
ServiceRequestRecord
{}
acc
:=
dao
.
ServiceRequestRecord
{}
redis
,
err
:=
client
.
GetRedisClien
t
()
db
,
err
:=
client
.
GetConnec
t
()
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
err
.
Error
())
fmt
.
Println
(
err
.
Error
())
return
return
...
@@ -99,7 +98,7 @@ func RecordCall(proxyData model.ProxyData, status int, res []byte) {
...
@@ -99,7 +98,7 @@ func RecordCall(proxyData model.ProxyData, status int, res []byte) {
if
status
!=
200
{
if
status
!=
200
{
acc
.
Error
=
string
(
res
)
acc
.
Error
=
string
(
res
)
}
}
acc
.
RequestTime
=
t
ools
.
JsonTime
(
time
.
Now
()
)
acc
.
RequestTime
=
t
ime
.
Now
(
)
acc
.
ApplyId
=
cast
.
ToInt
(
proxyData
.
ApplyId
)
acc
.
ApplyId
=
cast
.
ToInt
(
proxyData
.
ApplyId
)
acc
.
UserId
=
proxyData
.
ApplyUserId
acc
.
UserId
=
proxyData
.
ApplyUserId
acc
.
ServiceId
=
cast
.
ToInt
(
proxyData
.
ServiceId
)
acc
.
ServiceId
=
cast
.
ToInt
(
proxyData
.
ServiceId
)
...
@@ -110,13 +109,18 @@ func RecordCall(proxyData model.ProxyData, status int, res []byte) {
...
@@ -110,13 +109,18 @@ func RecordCall(proxyData model.ProxyData, status int, res []byte) {
acc
.
DateYear
=
time
.
Now
()
.
Year
()
acc
.
DateYear
=
time
.
Now
()
.
Year
()
acc
.
Status
=
status
acc
.
Status
=
status
b
,
_
:=
json
.
Marshal
(
acc
)
if
errs
:=
redis
.
Conn
.
RPush
(
config
.
CallRecord
,
b
)
.
Err
();
errs
!=
nil
{
if
_
,
err
=
db
.
Insert
(
&
acc
);
err
!=
nil
{
err
=
errs
fmt
.
Println
(
err
)
fmt
.
Println
(
"rpush data to list failed:"
,
errs
.
Error
())
return
}
}
fmt
.
Println
(
"调用记录进入队列"
)
//b, _ := json.Marshal(acc)
//if errs := redis.Conn.RPush(config.CallRecord, b).Err(); errs != nil {
// err = errs
// fmt.Println("rpush data to list failed:", errs.Error())
// return
//}
//fmt.Println("调用记录进入队列")
return
return
}
}
...
...
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