improve documentation for the ConnectionIDGenerator (#5043)

This commit is contained in:
Marten Seemann
2025-04-14 12:41:17 +08:00
committed by GitHub
parent 848c355079
commit 0ac0c1e72c

View File

@@ -242,21 +242,16 @@ func ConnectionIDFromBytes(b []byte) ConnectionID {
return protocol.ParseConnectionID(b) return protocol.ParseConnectionID(b)
} }
// A ConnectionIDGenerator is an interface that allows clients to implement their own format // A ConnectionIDGenerator allows the application to take control over the generation of Connection IDs.
// for the Connection IDs that servers/clients use as SrcConnectionID in QUIC packets. // Connection IDs generated by an implementation must be of constant length.
//
// Connection IDs generated by an implementation should always produce IDs of constant size.
type ConnectionIDGenerator interface { type ConnectionIDGenerator interface {
// GenerateConnectionID generates a new ConnectionID. // GenerateConnectionID generates a new Connection ID.
// Generated ConnectionIDs should be unique and observers should not be able to correlate two ConnectionIDs. // Generated Connection IDs must be unique and observers should not be able to correlate two Connection IDs.
GenerateConnectionID() (ConnectionID, error) GenerateConnectionID() (ConnectionID, error)
// ConnectionIDLen tells what is the length of the ConnectionIDs generated by the implementation of // ConnectionIDLen returns the length of Connection IDs generated by this implementation.
// this interface. // Implementations must return constant-length Connection IDs with lengths between 0 and 20 bytes.
// Effectively, this means that implementations of ConnectionIDGenerator must always return constant-size // A length of 0 can only be used when an endpoint doesn't need to multiplex connections during migration.
// connection IDs. Valid lengths are between 0 and 20 and calls to GenerateConnectionID.
// 0-length ConnectionsIDs can be used when an endpoint (server or client) does not require multiplexing connections
// in the presence of a connection migration environment.
ConnectionIDLen() int ConnectionIDLen() int
} }