/
clusterAccessLog.go
46 lines (35 loc) · 1.07 KB
/
clusterAccessLog.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package filter
import (
"time"
motan "github.com/weibocom/motan-go/core"
)
type ClusterAccessLogFilter struct {
next motan.ClusterFilter
}
func (t *ClusterAccessLogFilter) GetIndex() int {
return 1
}
func (t *ClusterAccessLogFilter) GetName() string {
return ClusterAccessLog
}
func (t *ClusterAccessLogFilter) NewFilter(url *motan.URL) motan.Filter {
return &ClusterAccessLogFilter{}
}
func (t *ClusterAccessLogFilter) Filter(haStrategy motan.HaStrategy, loadBalance motan.LoadBalance, request motan.Request) motan.Response {
start := time.Now()
response := t.GetNext().Filter(haStrategy, loadBalance, request)
doAccessLog(t.GetName(), clientAgentRole, "", time.Now().Sub(start).Nanoseconds()/1e6, request, response)
return response
}
func (t *ClusterAccessLogFilter) HasNext() bool {
return t.next != nil
}
func (t *ClusterAccessLogFilter) SetNext(nextFilter motan.ClusterFilter) {
t.next = nextFilter
}
func (t *ClusterAccessLogFilter) GetNext() motan.ClusterFilter {
return t.next
}
func (t *ClusterAccessLogFilter) GetType() int32 {
return motan.ClusterFilterType
}