mzq-test
This commit is contained in:
		
							
								
								
									
										22
									
								
								client.go
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								client.go
									
									
									
									
									
								
							@@ -110,6 +110,12 @@ func chainUnaryInterceptors(interceptors []UnaryClientInterceptor, final Invoker
 | 
				
			|||||||
// NewClient creates a new ttrpc client using the given connection
 | 
					// NewClient creates a new ttrpc client using the given connection
 | 
				
			||||||
func NewClient(conn net.Conn, opts ...ClientOpts) *Client {
 | 
					func NewClient(conn net.Conn, opts ...ClientOpts) *Client {
 | 
				
			||||||
	ctx, cancel := context.WithCancel(context.Background())
 | 
						ctx, cancel := context.WithCancel(context.Background())
 | 
				
			||||||
 | 
						a := log.Fields{
 | 
				
			||||||
 | 
							"mzq-test": true,
 | 
				
			||||||
 | 
							"conn":     fmt.Sprintf("%+v", conn),
 | 
				
			||||||
 | 
							"opts":     fmt.Sprintf("%+v", opts),
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						log.G(ctx).WithFields(a).Info("client.go NewClient")
 | 
				
			||||||
	channel := newChannel(conn)
 | 
						channel := newChannel(conn)
 | 
				
			||||||
	c := &Client{
 | 
						c := &Client{
 | 
				
			||||||
		codec:           codec{},
 | 
							codec:           codec{},
 | 
				
			||||||
@@ -338,6 +344,12 @@ func (c *Client) UserOnCloseWait(ctx context.Context) error {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func (c *Client) run() {
 | 
					func (c *Client) run() {
 | 
				
			||||||
	err := c.receiveLoop()
 | 
						err := c.receiveLoop()
 | 
				
			||||||
 | 
						a := log.Fields{
 | 
				
			||||||
 | 
							"mzq-test": true,
 | 
				
			||||||
 | 
							"c":        fmt.Sprintf("%+v", c),
 | 
				
			||||||
 | 
							"error":    err,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						log.G(c.ctx).WithFields(a).Errorf("ttrpc: received message on inactive stream")
 | 
				
			||||||
	c.Close()
 | 
						c.Close()
 | 
				
			||||||
	c.cleanupStreams(err)
 | 
						c.cleanupStreams(err)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -368,7 +380,15 @@ func (c *Client) receiveLoop() error {
 | 
				
			|||||||
			sid := streamID(msg.header.StreamID)
 | 
								sid := streamID(msg.header.StreamID)
 | 
				
			||||||
			s := c.getStream(sid)
 | 
								s := c.getStream(sid)
 | 
				
			||||||
			if s == nil {
 | 
								if s == nil {
 | 
				
			||||||
				log.G(c.ctx).WithField("stream", sid).Error("ttrpc: received message on inactive stream")
 | 
									a := log.Fields{
 | 
				
			||||||
 | 
										"mzq-test":    true,
 | 
				
			||||||
 | 
										"stream":      sid,
 | 
				
			||||||
 | 
										"c":           fmt.Sprintf("%+v", c),
 | 
				
			||||||
 | 
										"header":      msg.header,
 | 
				
			||||||
 | 
										"msg.header":  msg.header.Type.String(),
 | 
				
			||||||
 | 
										"msg.payload": string(msg.payload),
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									log.G(c.ctx).WithFields(a).Errorf("ttrpc: received message on inactive stream")
 | 
				
			||||||
				continue
 | 
									continue
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user