github.com/searKing/golang/go@v1.2.74/net/mux/conn_state.go (about)

     1  // Copyright 2020 The searKing Author. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package mux
     6  
     7  // A ConnState represents the state of a client connection to a server.
     8  // It's used by the optional Server.ConnStateHook hook.
     9  //go:generate go-enum -type ConnState -trimprefix=ConnState
    10  type ConnState int
    11  
    12  const (
    13  	// ConnStateNew represents a new connection that is expected to
    14  	// send a request immediately. Connections begin at this
    15  	// state and then transition to either ConnStateActive or
    16  	// ConnStateClosed.
    17  	ConnStateNew ConnState = iota
    18  
    19  	// ConnStateActive represents a connection that has read 1 or more
    20  	// bytes of a request. The Server.ConnStateHook hook for
    21  	// ConnStateActive fires before the request has entered a handler
    22  	// and doesn't fire again until the request has been
    23  	// handled. After the request is handled, the state
    24  	// transitions to ConnStateClosed, ConnStateHijacked, or ConnStateIdle.
    25  	// For HTTP/2, ConnStateActive fires on the transition from zero
    26  	// to one active request, and only transitions away once all
    27  	// active requests are complete. That means that ConnStateHook
    28  	// cannot be used to do per-request work; ConnStateHook only notes
    29  	// the overall state of the connection.
    30  	ConnStateActive
    31  
    32  	// ConnStateIdle represents a connection that has finished
    33  	// handling a request and is in the keep-alive state, waiting
    34  	// for a new request. Connections transition from ConnStateIdle
    35  	// to either ConnStateActive or ConnStateClosed.
    36  	ConnStateIdle
    37  
    38  	// ConnStateHijacked represents a hijacked connection.
    39  	// This is a terminal state. It does not transition to ConnStateClosed.
    40  	ConnStateHijacked
    41  
    42  	// ConnStateClosed represents a closed connection.
    43  	// This is a terminal state. Hijacked connections do not
    44  	// transition to ConnStateClosed.
    45  	ConnStateClosed
    46  )