diff --git a/client/call.go b/client/call.go index 167bb05..511600d 100644 --- a/client/call.go +++ b/client/call.go @@ -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{} diff --git a/client/client.go b/client/client.go index ad8cc50..baebb3a 100644 --- a/client/client.go +++ b/client/client.go @@ -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() diff --git a/client/client_handler.go b/client/client_handler.go index c2b8c58..bd3c946 100644 --- a/client/client_handler.go +++ b/client/client_handler.go @@ -16,6 +16,6 @@ type ClientHandler interface { GetRequestTimeout() time.Duration GetPendingRequests() int - GetRequestID() interface{} + GetRequestID() uint64 Validate() } diff --git a/client/client_handlers.go b/client/client_handlers.go index 997cdf8..0ae9620 100644 --- a/client/client_handlers.go +++ b/client/client_handlers.go @@ -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++