ing
This commit is contained in:
parent
5cad5b126d
commit
a8acaab5b8
|
@ -10,7 +10,7 @@ var callStatePool sync.Pool
|
|||
var zeroTime time.Time
|
||||
|
||||
type CallState struct {
|
||||
ID interface{}
|
||||
ID uint64
|
||||
Method string
|
||||
Args interface{}
|
||||
Result interface{}
|
||||
|
|
|
@ -34,7 +34,7 @@ type client struct {
|
|||
conn net.Conn
|
||||
|
||||
pendingRequestsCount uint32
|
||||
pendingRequests map[interface{}]*CallState
|
||||
pendingRequests map[uint64]*CallState
|
||||
pendingRequestsLock sync.Mutex
|
||||
|
||||
requestQueueChan chan *CallState
|
||||
|
@ -56,7 +56,7 @@ func (c *client) Connect() error {
|
|||
}
|
||||
c.stopChan = make(chan struct{})
|
||||
c.requestQueueChan = make(chan *CallState, c.ch.GetPendingRequests())
|
||||
c.pendingRequests = make(map[interface{}]*CallState)
|
||||
c.pendingRequests = make(map[uint64]*CallState)
|
||||
|
||||
go c.handleRPC()
|
||||
|
||||
|
@ -297,9 +297,9 @@ func (c *client) rpcReader(readerDone chan<- error) {
|
|||
|
||||
func (c *client) responseHandle(codecResponse protocol.ClientCodecResponse) error {
|
||||
c.pendingRequestsLock.Lock()
|
||||
cs, ok := c.pendingRequests[codecResponse.ID()]
|
||||
cs, ok := c.pendingRequests[codecResponse.ID().(uint64)]
|
||||
if ok {
|
||||
delete(c.pendingRequests, codecResponse.ID())
|
||||
delete(c.pendingRequests, codecResponse.ID().(uint64))
|
||||
}
|
||||
c.pendingRequestsLock.Unlock()
|
||||
|
||||
|
|
|
@ -16,6 +16,6 @@ type ClientHandler interface {
|
|||
GetRequestTimeout() time.Duration
|
||||
GetPendingRequests() int
|
||||
|
||||
GetRequestID() interface{}
|
||||
GetRequestID() uint64
|
||||
Validate()
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ func (ch *ClientHandlers) GetPendingRequests() int {
|
|||
return ch.PendingRequests
|
||||
}
|
||||
|
||||
func (ch *ClientHandlers) GetRequestID() interface{} {
|
||||
func (ch *ClientHandlers) GetRequestID() uint64 {
|
||||
var id uint64
|
||||
ch.requestIDMtx.Lock()
|
||||
ch.requestID++
|
||||
|
|
Loading…
Reference in New Issue
Block a user