Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Commit c4477f9

Browse files
committed
[proxy]使用easyjson代替部分ffjson来提升性能
1 parent 71e7435 commit c4477f9

9 files changed

Lines changed: 1540 additions & 6131 deletions

File tree

tealogs/access_log_queue.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"github.com/TeaWeb/code/tealogs/accesslogs"
77
"github.com/TeaWeb/code/teautils"
88
"github.com/iwind/TeaGo/logs"
9-
"github.com/pquerna/ffjson/ffjson"
9+
"github.com/mailru/easyjson"
1010
"github.com/syndtr/goleveldb/leveldb"
1111
"strconv"
1212
"sync"
@@ -56,7 +56,7 @@ func (this *AccessLogQueue) Receive(ch chan *accesslogs.AccessLog) {
5656
// 保存到文件
5757
if log.ShouldWrite() {
5858
log.CleanFields()
59-
data, err := ffjson.Marshal(log)
59+
data, err := easyjson.Marshal(log)
6060
if err != nil {
6161
logs.Error(err)
6262
continue
@@ -145,7 +145,7 @@ func (this *AccessLogQueue) dumpInterval() {
145145
continue
146146
}
147147
accessLog := new(accesslogs.AccessLog)
148-
err = ffjson.Unmarshal(value, accessLog)
148+
err = easyjson.Unmarshal(value, accessLog)
149149
if err != nil {
150150
logs.Error(err)
151151
err = this.db.Delete(key, nil)

tealogs/accesslogs/access_log.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/iwind/TeaGo/lists"
1111
"github.com/iwind/TeaGo/logs"
1212
"github.com/iwind/TeaGo/maps"
13+
"github.com/mailru/easyjson"
1314
"github.com/pquerna/ffjson/ffjson"
1415
"path/filepath"
1516
"reflect"
@@ -189,7 +190,7 @@ func (this *AccessLog) Format(format string) string {
189190

190191
// json log
191192
if varName == "log" {
192-
data, _ := ffjson.Marshal(this)
193+
data, _ := easyjson.Marshal(this)
193194
return string(data)
194195
}
195196

0 commit comments

Comments
 (0)