Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update httpfast & accesslog #401

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
testing:
strategy:
matrix:
go-version: [1.16.x,1.17.x,1.18.x,1.19.x,1.20.x,1.21.x]
go-version: [1.20.x,1.21.x]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand All @@ -45,10 +45,10 @@ jobs:
name: codecov
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.16
- name: Set up Go 1.20
uses: actions/setup-go@v3
with:
go-version: 1.16.x
go-version: 1.20.x
id: go

- name: Checkout code
Expand Down
6 changes: 5 additions & 1 deletion filter/accessLog.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package filter
import (
"encoding/json"
motan "github.com/weibocom/motan-go/core"
"github.com/weibocom/motan-go/log"
vlog "github.com/weibocom/motan-go/log"
"strconv"
"time"
)
Expand Down Expand Up @@ -56,6 +56,10 @@ func (t *AccessLogFilter) Filter(caller motan.Caller, request motan.Request) mot
resCtx.AddFinishHandler(motan.FinishHandleFunc(func() {
totalTime := reqCtx.ResponseSendTime.Sub(reqCtx.RequestReceiveTime).Nanoseconds() / 1e6
doAccessLog(t.GetName(), role, address, totalTime, request, response)
finalResCtx := response.GetRPCContext(true)
if finalResCtx.BodySize == 5 {
vlog.Warningf("bad response. content:%v, resAttachment:%v, reqArgs:%v, req: %+v, res:%+v", response.GetValue(), response.GetAttachments(), request.GetArguments(), request, response)
}
}))
} else {
doAccessLog(t.GetName(), role, address, time.Now().Sub(start).Nanoseconds()/1e6, request, response)
Expand Down
36 changes: 23 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,42 +1,52 @@
module github.com/weibocom/motan-go

go 1.16
go 1.20

require (
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5
github.com/beberlei/fastcgi-serve v0.0.0-20151230120321-4676005f65b7
github.com/buraksezer/consistent v0.10.0
github.com/cespare/xxhash/v2 v2.2.0
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/golang/protobuf v1.3.2
github.com/juju/ratelimit v1.0.1
github.com/klauspost/compress v1.4.1 // indirect
github.com/klauspost/cpuid v1.2.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/mitchellh/mapstructure v1.1.2
github.com/opentracing/opentracing-go v1.0.2
github.com/panjf2000/ants/v2 v2.9.0
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a
github.com/samuel/go-zookeeper v0.0.0-20180130194729-c4fab1ac1bec
github.com/shirou/gopsutil/v3 v3.21.9
github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/stretchr/testify v1.8.4
github.com/valyala/fasthttp v1.2.0
github.com/valyala/fasthttp v1.55.0
github.com/weibreeze/breeze-go v0.1.1
go.uber.org/atomic v1.4.0
go.uber.org/multierr v1.1.0 // indirect
go.uber.org/zap v1.10.0
golang.org/x/net v0.0.0-20201224014010-6772e930b67b
golang.org/x/text v0.3.3 // indirect
golang.org/x/net v0.26.0
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a // indirect
google.golang.org/grpc v1.21.1
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/yaml.v2 v2.2.4
)

require (
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-ole/go-ole v1.2.5 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/pkg/errors v0.8.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/tklauser/go-sysconf v0.3.9 // indirect
github.com/tklauser/numcpus v0.3.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
go.uber.org/multierr v1.1.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
)

replace (
cloud.google.com/go => github.com/GoogleCloudPlatform/google-cloud-go v0.30.0
github.com/stretchr/testify => github.com/stretchr/testify v1.2.2
Expand Down
1 change: 1 addition & 0 deletions provider/httpProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ func (h *HTTPProvider) DoProxy(request motan.Request, t int64, ip string) motan.
httpReq.URI().SetScheme(h.proxySchema)
httpReq.URI().SetPath(rewritePath)
if len(httpReq.Header.Host()) == 0 {
httpReq.UseHostHeader = true
httpReq.Header.SetHost(h.domain)
}
if httpReq.Header.Peek(motan.XForwardedFor) == nil {
Expand Down
Loading