github.com/GeniusesGroup/libgo@v0.0.0-20220929090155-5ff932cb408e/protocol/networking-connections.go (about)

     1  /* For license and copyright information please see the LEGAL file in the code repository */
     2  
     3  package protocol
     4  
     5  type Connections interface {
     6  	GetConnectionByPeerAddr(addr [16]byte) (conn Connection, err Error)
     7  	// A connection can use just by single app node, so user can't use same connection to connect other node before close connection on usage node.
     8  	GetConnectionByUserIDDelegateUserID(userID, delegateUserID [16]byte) (conn Connection, err Error)
     9  	GetConnectionsByUserID(userID [16]byte) (conns []Connection, err Error)
    10  	GetConnectionByDomain(domain string) (conn Connection, err Error)
    11  
    12  	// state=unregistered -> 'register' -> state=registered -> 'deregister' -> state=unregistered.
    13  	RegisterConnection(conn Connection) (err Error)
    14  	DeregisterConnection(conn Connection) (err Error)
    15  
    16  	ConnectionsMetrics
    17  }
    18  
    19  // ConnectionMetrics
    20  type ConnectionsMetrics interface {
    21  	LastUsage() Time   // Last use of the connection
    22  	OpenCount() int64  // number of opened and pending open connections
    23  	InUseCount() int64 // The number of connections currently in use.
    24  	IdleCount() int64  // The number of idle connections.
    25  
    26  	GuestConnectionCount() int64
    27  	ClosedCount() int64         // ClosedCount is an atomic counter which represents a total number of closed connections.
    28  	WaitCount() int64           // Total number of connections waited for.
    29  	IdleClosedCount() int64     // Total number of connections closed due to idle count.
    30  	IdleTimeClosedCount() int64 // Total number of connections closed due to idle time.
    31  	LifetimeClosedCount() int64 // Total number of connections closed due to max connection lifetime limit.
    32  
    33  	// Rate() uint // Byte/Second
    34  }