diff options
author | Rastislav Szabo <raszabo@cisco.com> | 2018-07-09 07:56:15 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@fd.io> | 2018-07-09 07:56:15 +0000 |
commit | a679bbc78b98089f9b221bbe7de963f5274073bb (patch) | |
tree | 09efc26e2a6d8c01f9e18aeaf8345ecec6154711 /core/request_handler.go | |
parent | 3f26790b479f8a0cab00093b83491e9f47648b56 (diff) | |
parent | f1bef4a3c66f4408afdeb64cda62ccd8562d0fc6 (diff) |
Merge "make api.Channel as interface"
Diffstat (limited to 'core/request_handler.go')
-rw-r--r-- | core/request_handler.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/core/request_handler.go b/core/request_handler.go index 3bec38d..8681963 100644 --- a/core/request_handler.go +++ b/core/request_handler.go @@ -31,10 +31,10 @@ var ( ) // watchRequests watches for requests on the request API channel and forwards them as messages to VPP. -func (c *Connection) watchRequests(ch *api.Channel) { +func (c *Connection) watchRequests(ch *channel) { for { select { - case req, ok := <-ch.ReqChan: + case req, ok := <-ch.reqChan: // new request on the request channel if !ok { // after closing the request channel, release API channel and return @@ -43,7 +43,7 @@ func (c *Connection) watchRequests(ch *api.Channel) { } c.processRequest(ch, req) - case req := <-ch.NotifSubsChan: + case req := <-ch.notifSubsChan: // new request on the notification subscribe channel c.processNotifSubscribeRequest(ch, req) } @@ -51,7 +51,7 @@ func (c *Connection) watchRequests(ch *api.Channel) { } // processRequest processes a single request received on the request channel. -func (c *Connection) processRequest(ch *api.Channel, req *api.VppRequest) error { +func (c *Connection) processRequest(ch *channel, req *api.VppRequest) error { // check whether we are connected to VPP if atomic.LoadUint32(&c.connected) == 0 { err := ErrNotConnected @@ -78,7 +78,7 @@ func (c *Connection) processRequest(ch *api.Channel, req *api.VppRequest) error if err != nil { err = fmt.Errorf("unable to encode the messge: %v", err) log.WithFields(logger.Fields{ - "channel": ch.ID, + "channel": ch.id, "msg_id": msgID, "seq_num": req.SeqNum, }).Error(err) @@ -88,7 +88,7 @@ func (c *Connection) processRequest(ch *api.Channel, req *api.VppRequest) error if log.Level == logger.DebugLevel { // for performance reasons - logrus does some processing even if debugs are disabled log.WithFields(logger.Fields{ - "channel": ch.ID, + "channel": ch.id, "msg_id": msgID, "msg_size": len(data), "msg_name": req.Message.GetMessageName(), @@ -97,7 +97,7 @@ func (c *Connection) processRequest(ch *api.Channel, req *api.VppRequest) error } // send the request to VPP - context := packRequestContext(ch.ID, req.Multipart, req.SeqNum) + context := packRequestContext(ch.id, req.Multipart, req.SeqNum) err = c.vpp.SendMsg(context, data) if err != nil { err = fmt.Errorf("unable to send the message: %v", err) @@ -189,9 +189,9 @@ func msgCallback(context uint32, msgID uint16, data []byte) { // sendReply sends the reply into the go channel, if it cannot be completed without blocking, otherwise // it logs the error and do not send the message. -func sendReply(ch *api.Channel, reply *api.VppReply) { +func sendReply(ch *channel, reply *api.VppReply) { select { - case ch.ReplyChan <- reply: + case ch.replyChan <- reply: // reply sent successfully case <-time.After(time.Millisecond * 100): // receiver still not ready |