Renaming analyzers NewServerCodec to NewAnalyzerServerCodec

This commit is contained in:
DanB
2020-12-24 11:53:05 +01:00
parent 0c27718bd5
commit ed12d98fba
4 changed files with 8 additions and 6 deletions

View File

@@ -24,7 +24,7 @@ import (
"time"
)
func NewServerCodec(sc rpc.ServerCodec, aS *AnalyzerService, enc, from, to string) rpc.ServerCodec {
func NewAnalyzerServerCodec(sc rpc.ServerCodec, aS *AnalyzerService, enc, from, to string) rpc.ServerCodec {
return &AnalyzerServerCodec{
sc: sc,
reqs: make(map[uint64]*rpcAPI),
@@ -68,6 +68,7 @@ func (c *AnalyzerServerCodec) ReadRequestBody(x interface{}) (err error) {
c.reqsLk.Unlock()
return
}
func (c *AnalyzerServerCodec) WriteResponse(r *rpc.Response, x interface{}) error {
c.reqsLk.Lock()
api := c.reqs[c.reqIdx]
@@ -76,4 +77,5 @@ func (c *AnalyzerServerCodec) WriteResponse(r *rpc.Response, x interface{}) erro
go c.aS.logTrafic(api.ID, api.Method, api.Params, x, r.Error, c.enc, c.from, c.to, api.StartTime, time.Now())
return c.sc.WriteResponse(r, x)
}
func (c *AnalyzerServerCodec) Close() error { return c.sc.Close() }

View File

@@ -61,7 +61,7 @@ func TestNewServerCodec(t *testing.T) {
t.Fatal(err)
}
codec := NewServerCodec(new(mockServerCodec), anz, utils.MetaJSON, "127.0.0.1:5565", "127.0.0.1:2012")
codec := NewAnalyzerServerCodec(new(mockServerCodec), anz, utils.MetaJSON, "127.0.0.1:5565", "127.0.0.1:2012")
r := new(rpc.Request)
expR := &rpc.Request{
Seq: 0,