github.com/searKing/golang/go@v1.2.117/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  //
    10  //go:generate go-enum -type ConnState -trimprefix=ConnState
    11  type ConnState int
    12  
    13  const (
    14  	// ConnStateNew represents a new connection that is expected to
    15  	// send a request immediately. Connections begin at this
    16  	// state and then transition to either ConnStateActive or
    17  	// ConnStateClosed.
    18  	ConnStateNew ConnState = iota
    19  
    20  	// ConnStateActive represents a connection that has read 1 or more
    21  	// bytes of a request. The Server.ConnStateHook hook for
    22  	// ConnStateActive fires before the request has entered a handler
    23  	// and doesn't fire again until the request has been
    24  	// handled. After the request is handled, the state
    25  	// transitions to ConnStateClosed, ConnStateHijacked, or ConnStateIdle.
    26  	// For HTTP/2, ConnStateActive fires on the transition from zero
    27  	// to one active request, and only transitions away once all
    28  	// active requests are complete. That means that ConnStateHook
    29  	// cannot be used to do per-request work; ConnStateHook only notes
    30  	// the overall state of the connection.
    31  	ConnStateActive
    32  
    33  	// ConnStateIdle represents a connection that has finished
    34  	// handling a request and is in the keep-alive state, waiting
    35  	// for a new request. Connections transition from ConnStateIdle
    36  	// to either ConnStateActive or ConnStateClosed.
    37  	ConnStateIdle
    38  
    39  	// ConnStateHijacked represents a hijacked connection.
    40  	// This is a terminal state. It does not transition to ConnStateClosed.
    41  	ConnStateHijacked
    42  
    43  	// ConnStateClosed represents a closed connection.
    44  	// This is a terminal state. Hijacked connections do not
    45  	// transition to ConnStateClosed.
    46  	ConnStateClosed
    47  )