// dispatchInbound ispatches an inbound call to the appropriate handler
dispatchInbound ispatches an inbound call to the appropriate handler
// dispatchInbound ispatches an inbound call to the appropriate handler
func (c *Connection) dispatchInbound(_ uint32, _ uint32, call *InboundCall, frame *Frame) {
	if call.log.Enabled(LogLevelDebug) {
		call.log.Debugf("Received incoming call for %s from %s", call.ServiceName(), c.remotePeerInfo)
	}
	if err := call.readMethod(); err != nil {
		call.log.WithFields(
			LogField{"remotePeer", c.remotePeerInfo},
			ErrField(err),
		).Error("Couldn't read method.")
		c.opts.FramePool.Release(frame)
		return
	}
	call.commonStatsTags["endpoint"] = call.methodString
	call.statsReporter.IncCounter("inbound.calls.recvd", call.commonStatsTags, 1)
	if span := call.response.span; span != nil {
		span.SetOperationName(call.methodString)
	}
	go func() {
		select {
		case <-call.mex.ctx.Done():
			if call.mex.ctx.Err() != nil {
				call.mex.inboundExpired()
			}
		case <-call.mex.errCh.c:
			if c.log.Enabled(LogLevelDebug) {
				call.log.Debugf("Wait for timeout/cancellation interrupted by error: %v", call.mex.errCh.err)
			}
			call.response.cancel()
			call.mex.inboundExpired()
		}
	}()
	if call.ServiceName() == "tchannel" {
		if h := c.internalHandlers.find(call.Method()); h != nil {
			h.Handle(call.mex.ctx, call)
			return
		}
	}
	c.handler.Handle(call.mex.ctx, call)
}
func ( c * Connection ) dispatchInbound ( _ uint32 , _ uint32 , call * InboundCall , frame * Frame ) { if call . log . Enabled ( LogLevelDebug ) { call . log . Debugf ( " " , call . ServiceName ( ) , c . remotePeerInfo ) } if err := call . readMethod ( ) ; err != nil { call . log . WithFields ( LogField { " " , c . remotePeerInfo } , ErrField ( err ) , ) . Error ( " " ) c . opts . FramePool . Release ( frame ) return } call . commonStatsTags [ " " ] = call . methodString call . statsReporter . IncCounter ( " " , call . commonStatsTags , 1 ) if span := call . response . span ; span != nil { span . SetOperationName ( call . methodString ) } go func ( ) { select { case <- call . mex . ctx . Done ( ) : if call . mex . ctx . Err ( ) != nil { call . mex . inboundExpired ( ) } case <- call . mex . errCh . c : if c . log . Enabled ( LogLevelDebug ) { call . log . Debugf ( " " , call . mex . errCh . err ) } call . response . cancel ( ) call . mex . inboundExpired ( ) } } ( ) if call . ServiceName ( ) == " " { if h := c . internalHandlers . find ( call . Method ( ) ) ; h != nil { h . Handle ( call . mex . ctx , call ) return } } c . handler . Handle ( call . mex . ctx , call ) }
dispatchInbound ispatches an inbound call to the appropriate handler
dispatchInbound ispatches an inbound call to the appropriate handler
// TODO(prashant): This is an expensive way to check for cancellation. Use a heap for timeouts. // checking if message exchange timedout or was cancelled // only two possible errors at this step: // context.DeadlineExceeded // context.Canceled // when an exchange errors out, mark the exchange as expired // and call cancel so the server handler's context is canceled // TODO: move the cancel to the parent context at connnection level // Internal handlers (e.g., introspection) trump all other user-registered handlers on // the "tchannel" name.