This commit is contained in:
crusader 2017-11-01 17:43:20 +09:00
parent 5cad5b126d
commit a8acaab5b8
4 changed files with 7 additions and 7 deletions

View File

@ -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{}

View File

@ -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()

View File

@ -16,6 +16,6 @@ type ClientHandler interface {
GetRequestTimeout() time.Duration
GetPendingRequests() int
GetRequestID() interface{}
GetRequestID() uint64
Validate()
}

View File

@ -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++