Documentation
¶
Overview ¶
Package zmux implements the zmux v1 single-connection stream multiplexer.
It exposes Session and Stream interfaces for multiplexed streams over one transport connection.
Wire codecs, protocol-state helpers, and runtime policy stay in internal packages:
- internal/wire
- internal/state
- internal/runtime
Treat internal packages as implementation details.
Index ¶
- Constants
- Variables
- func AppendTLV(dst []byte, typ uint64, value []byte) ([]byte, error)
- func AppendVarint(dst []byte, v uint64) ([]byte, error)
- func ConfigureDefaultConfig(fn func(*Config))
- func EncodeVarint(v uint64) ([]byte, error)
- func IsErrorCode(err error, code ErrorCode) bool
- func ParseVarint(src []byte) (uint64, int, error)
- func ReadVarint(r io.ByteReader) (uint64, int, error)
- func ReferenceProfileClaimGate() []string
- func ResetDefaultConfig()
- func VarintLen(v uint64) (int, error)
- type AcceptBacklogStats
- type ActiveStreamStats
- type ApplicationError
- type Capabilities
- type Claim
- type Config
- type ConformanceSuite
- type Conn
- func Client(conn io.ReadWriteCloser, cfg *Config) (*Conn, error)
- func ClientIO(reader io.Reader, writer io.Writer, cfg *Config) (*Conn, error)
- func New(conn io.ReadWriteCloser, cfg *Config) (*Conn, error)
- func NewIO(reader io.Reader, writer io.Writer, cfg *Config) (*Conn, error)
- func Server(conn io.ReadWriteCloser, cfg *Config) (*Conn, error)
- func ServerIO(reader io.Reader, writer io.Writer, cfg *Config) (*Conn, error)
- func (c *Conn) AcceptStream(ctx context.Context) (NativeStream, error)
- func (c *Conn) AcceptUniStream(ctx context.Context) (NativeRecvStream, error)
- func (c *Conn) Close() error
- func (c *Conn) CloseWithError(err error)
- func (c *Conn) Closed() bool
- func (c *Conn) GoAway(lastAcceptedBidi, lastAcceptedUni uint64) error
- func (c *Conn) GoAwayWithError(lastAcceptedBidi, lastAcceptedUni, code uint64, reason string) error
- func (c *Conn) LocalPreface() Preface
- func (c *Conn) Negotiated() Negotiated
- func (c *Conn) OpenAndSend(ctx context.Context, p []byte) (NativeStream, int, error)
- func (c *Conn) OpenAndSendWithOptions(ctx context.Context, opts OpenOptions, p []byte) (NativeStream, int, error)
- func (c *Conn) OpenStream(ctx context.Context) (NativeStream, error)
- func (c *Conn) OpenStreamWithOptions(ctx context.Context, opts OpenOptions) (NativeStream, error)
- func (c *Conn) OpenUniAndSend(ctx context.Context, p []byte) (NativeSendStream, int, error)
- func (c *Conn) OpenUniAndSendWithOptions(ctx context.Context, opts OpenOptions, p []byte) (NativeSendStream, int, error)
- func (c *Conn) OpenUniStream(ctx context.Context) (NativeSendStream, error)
- func (c *Conn) OpenUniStreamWithOptions(ctx context.Context, opts OpenOptions) (NativeSendStream, error)
- func (c *Conn) PeerCloseError() *ApplicationError
- func (c *Conn) PeerGoAwayError() *ApplicationError
- func (c *Conn) PeerPreface() Preface
- func (c *Conn) Ping(ctx context.Context, echo []byte) (time.Duration, error)
- func (c *Conn) State() SessionState
- func (c *Conn) Stats() SessionStats
- func (c *Conn) Wait(ctx context.Context) error
- type DIAGType
- type DiagnosticStats
- type Direction
- type DuplexByteStream
- type EXTSubtype
- type Error
- type ErrorCode
- type Event
- type EventHandler
- type EventType
- type FlushStats
- type Frame
- type FrameType
- type HiddenStats
- type ImplementationProfile
- func (p ImplementationProfile) AcceptanceChecklist() []string
- func (p ImplementationProfile) Claims() []Claim
- func (p ImplementationProfile) ReleaseCertificationGate() []ConformanceSuite
- func (p ImplementationProfile) RequiredConformanceSuites() []ConformanceSuite
- func (p ImplementationProfile) Valid() bool
- type JoinedConn
- func (c *JoinedConn) Close() error
- func (c *JoinedConn) CloseRead() error
- func (c *JoinedConn) CloseWrite() error
- func (c *JoinedConn) LocalAddr() net.Addr
- func (c *JoinedConn) PauseRead(ctx context.Context) (*PausedReadHalf, error)
- func (c *JoinedConn) PauseWrite(ctx context.Context) (*PausedWriteHalf, error)
- func (c *JoinedConn) Read(p []byte) (int, error)
- func (c *JoinedConn) ReadHalf() ReadHalf
- func (c *JoinedConn) RemoteAddr() net.Addr
- func (c *JoinedConn) SetDeadline(t time.Time) error
- func (c *JoinedConn) SetReadDeadline(t time.Time) error
- func (c *JoinedConn) SetWriteDeadline(t time.Time) error
- func (c *JoinedConn) Write(p []byte) (int, error)
- func (c *JoinedConn) WriteHalf() WriteHalf
- type Limits
- type MetadataUpdate
- type NativeRecvStream
- type NativeSendStream
- type NativeSession
- type NativeStream
- type Negotiated
- type OpenOptions
- type Operation
- type PausedReadHalf
- type PausedWriteHalf
- type Preface
- type PressureStats
- type ProgressStats
- type ProvisionalStats
- type QueueStats
- type ReadHalf
- type ReasonStats
- type RecvStream
- type RetainedBucketStats
- type RetainedStateBreakdown
- type Role
- type SchedulerHint
- type Scope
- type SendStream
- type Session
- func AsSession(conn *Conn) Session
- func ClientIOSession(reader io.Reader, writer io.Writer, cfg *Config) (Session, error)
- func ClientSession(conn io.ReadWriteCloser, cfg *Config) (Session, error)
- func NewIOSession(reader io.Reader, writer io.Writer, cfg *Config) (Session, error)
- func NewSession(conn io.ReadWriteCloser, cfg *Config) (Session, error)
- func ServerIOSession(reader io.Reader, writer io.Writer, cfg *Config) (Session, error)
- func ServerSession(conn io.ReadWriteCloser, cfg *Config) (Session, error)
- type SessionState
- type SessionStats
- type SettingID
- type Settings
- type Source
- type Stream
- type StreamMetadata
- type StreamMetadataType
- type TLV
- type TerminationKind
- type WireError
- type WriteHalf
Constants ¶
const ( Magic = wire.Magic PrefaceVersion = wire.PrefaceVersion ProtoVersion = wire.ProtoVersion MaxPrefaceSettingsBytes = wire.MaxPrefaceSettingsBytes MaxVarint62 = wire.MaxVarint62 )
const ( RoleInitiator = wire.RoleInitiator RoleResponder = wire.RoleResponder RoleAuto = wire.RoleAuto )
const ( SchedulerUnspecifiedOrBalanced = wire.SchedulerUnspecifiedOrBalanced SchedulerLatency = wire.SchedulerLatency SchedulerBalancedFair = wire.SchedulerBalancedFair SchedulerBulkThroughput = wire.SchedulerBulkThroughput SchedulerGroupFair = wire.SchedulerGroupFair )
const ( CapabilityPriorityHints = wire.CapabilityPriorityHints CapabilityStreamGroups = wire.CapabilityStreamGroups CapabilityMultilinkBasicRetired = wire.CapabilityMultilinkBasicRetired CapabilityMultilinkBasic = wire.CapabilityMultilinkBasic CapabilityPriorityUpdate = wire.CapabilityPriorityUpdate CapabilityOpenMetadata = wire.CapabilityOpenMetadata )
const ( SettingInitialMaxStreamDataBidiLocallyOpened = wire.SettingInitialMaxStreamDataBidiLocallyOpened SettingInitialMaxStreamDataBidiPeerOpened = wire.SettingInitialMaxStreamDataBidiPeerOpened SettingInitialMaxStreamDataUni = wire.SettingInitialMaxStreamDataUni SettingInitialMaxData = wire.SettingInitialMaxData SettingMaxIncomingStreamsBidi = wire.SettingMaxIncomingStreamsBidi SettingMaxIncomingStreamsUni = wire.SettingMaxIncomingStreamsUni SettingMaxFramePayload = wire.SettingMaxFramePayload SettingIdleTimeoutMillis = wire.SettingIdleTimeoutMillis SettingKeepaliveHintMillis = wire.SettingKeepaliveHintMillis SettingMaxControlPayloadBytes = wire.SettingMaxControlPayloadBytes SettingMaxExtensionPayloadBytes = wire.SettingMaxExtensionPayloadBytes SettingSchedulerHints = wire.SettingSchedulerHints SettingPingPaddingKey = wire.SettingPingPaddingKey SettingPrefacePadding = wire.SettingPrefacePadding )
const ( FrameTypeDATA = wire.FrameTypeDATA FrameTypeMAXDATA = wire.FrameTypeMAXDATA FrameTypeStopSending = wire.FrameTypeStopSending FrameTypePING = wire.FrameTypePING FrameTypePONG = wire.FrameTypePONG FrameTypeBLOCKED = wire.FrameTypeBLOCKED FrameTypeRESET = wire.FrameTypeRESET FrameTypeABORT = wire.FrameTypeABORT FrameTypeGOAWAY = wire.FrameTypeGOAWAY FrameTypeCLOSE = wire.FrameTypeCLOSE FrameTypeEXT = wire.FrameTypeEXT )
const ( FrameFlagOpenMetadata = wire.FrameFlagOpenMetadata FrameFlagFIN = wire.FrameFlagFIN )
const ( MetadataStreamPriority = wire.MetadataStreamPriority MetadataStreamGroup = wire.MetadataStreamGroup MetadataOpenInfo = wire.MetadataOpenInfo )
const ( DIAGDebugText = wire.DIAGDebugText DIAGRetryAfterMillis = wire.DIAGRetryAfterMillis DIAGOffendingStreamID = wire.DIAGOffendingStreamID DIAGOffendingFrameType = wire.DIAGOffendingFrameType )
const ( EXTPriorityUpdate = wire.EXTPriorityUpdate ExtMLReadyRetired = wire.ExtMLReadyRetired ExtMLAttachRetired = wire.ExtMLAttachRetired ExtMLAttachAckRetired = wire.ExtMLAttachAckRetired ExtMLDrainReqRetired = wire.ExtMLDrainReqRetired ExtMLDrainAckRetired = wire.ExtMLDrainAckRetired )
const ( CodeNoError = wire.CodeNoError CodeProtocol = wire.CodeProtocol CodeFlowControl = wire.CodeFlowControl CodeStreamLimit = wire.CodeStreamLimit CodeRefusedStream = wire.CodeRefusedStream CodeStreamState = wire.CodeStreamState CodeStreamClosed = wire.CodeStreamClosed CodeSessionClosing = wire.CodeSessionClosing CodeCancelled = wire.CodeCancelled CodeIdleTimeout = wire.CodeIdleTimeout CodeFrameSize = wire.CodeFrameSize CodeUnsupportedVersion = wire.CodeUnsupportedVersion CodeRoleConflict = wire.CodeRoleConflict CodeInternal = wire.CodeInternal )
Variables ¶
var ( ErrNilConn = errors.New("zmux: nil conn") ErrSessionClosed = errors.New("zmux: session closed") ErrReadClosed = errors.New("zmux: read side closed") ErrWriteClosed = errors.New("zmux: write side closed") ErrStreamNotReadable = errors.New("zmux: stream is not readable") ErrStreamNotWritable = errors.New("zmux: stream is not writable") ErrOpenMetadataTooLarge = wire.ErrOpenMetadataTooLarge ErrOpenLimited = errors.New("zmux: too many provisional local opens") ErrOpenExpired = errors.New("zmux: provisional local open expired before first-frame commit") ErrAdapterUnsupported = errors.New("zmux: feature not supported by adapter") ErrPriorityUpdateTooLarge = errors.New("zmux: priority update exceeds peer max_extension_payload_bytes") ErrGracefulCloseTimeout = errors.New("zmux: graceful close drain timed out") ErrEmptyMetadataUpdate = errors.New("zmux: metadata update has no fields") ErrKeepaliveTimeout = errors.New("zmux: keepalive timeout") )
Functions ¶
func ConfigureDefaultConfig ¶ added in v1.1.0
func ConfigureDefaultConfig(fn func(*Config))
ConfigureDefaultConfig mutates the process-wide default configuration template used by DefaultConfig and by constructors called with nil Config.
Call it during process initialization before creating sessions. Existing sessions are not affected. Concurrent calls are race-safe; last write wins.
Per-session random fields are not retained in the template: TieBreakerNonce and Settings.PingPaddingKey are cleared after fn returns so each session can generate fresh values.
func EncodeVarint ¶
func IsErrorCode ¶
IsErrorCode reports whether err carries the given wire or application code.
func ReadVarint ¶
func ReadVarint(r io.ByteReader) (uint64, int, error)
func ReferenceProfileClaimGate ¶
func ReferenceProfileClaimGate() []string
ReferenceProfileClaimGate returns the repository-defined reference-profile gate conditions from the current zmux document set. The returned slice is a copy and may be modified by the caller.
func ResetDefaultConfig ¶ added in v1.1.0
func ResetDefaultConfig()
ResetDefaultConfig restores the built-in process-wide default configuration template.
Types ¶
type AcceptBacklogStats ¶
type AcceptBacklogStats struct {
Count int
CountLimit int
AtCountCap bool
Bytes uint64
BytesLimit uint64
AtBytesCap bool
Refused uint64
}
AcceptBacklogStats reports accepted-stream backlog usage.
type ActiveStreamStats ¶ added in v1.0.9
type ActiveStreamStats struct {
// LocalBidi counts active bidirectional streams opened by this endpoint.
LocalBidi uint64
// LocalUni counts active send-only streams opened by this endpoint.
LocalUni uint64
// PeerBidi counts active bidirectional streams opened by the peer.
PeerBidi uint64
// PeerUni counts active receive-only streams opened by the peer.
PeerUni uint64
// Total is the saturating sum of all active stream counters.
Total uint64
}
ActiveStreamStats reports active stream slots by opener and direction.
type ApplicationError ¶
ApplicationError carries an application code and optional reason text.
func (*ApplicationError) ApplicationCode ¶
func (e *ApplicationError) ApplicationCode() uint64
func (*ApplicationError) Error ¶
func (e *ApplicationError) Error() string
func (*ApplicationError) Is ¶
func (e *ApplicationError) Is(err error) bool
type Capabilities ¶
type Capabilities = wire.Capabilities
type Claim ¶
type Claim string
Claim identifies one repository-defined standardized claim string from the zmux document set.
func CoreModuleTargetClaims ¶ added in v1.1.0
func CoreModuleTargetClaims() []Claim
CoreModuleTargetClaims returns the repository-defined conformance claims targeted by the core zmux module. The returned slice is a copy and may be modified by the caller.
func KnownClaims ¶
func KnownClaims() []Claim
KnownClaims returns the repository-defined claim names recognized by this package. The returned slice is a copy and may be modified by the caller.
func (Claim) AcceptanceChecklist ¶
AcceptanceChecklist returns the repository-defined minimum acceptance checklist for the claim. The returned slice is a copy and may be modified by the caller.
func (Claim) RequiredConformanceSuites ¶
func (c Claim) RequiredConformanceSuites() []ConformanceSuite
RequiredConformanceSuites returns the repository-defined local suite selection buckets needed to substantiate the claim.
type Config ¶
type Config struct {
Role Role
TieBreakerNonce uint64
MinProto uint64
MaxProto uint64
Capabilities Capabilities
Settings Settings
NonceSource io.Reader
// PrefacePadding adds one ignored settings TLV to the local preface.
PrefacePadding bool
// PrefacePaddingMinBytes is the lower padding length bound. Zero uses the default.
PrefacePaddingMinBytes uint64
// PrefacePaddingMaxBytes is the upper padding length bound. Zero uses the default.
PrefacePaddingMaxBytes uint64
// KeepaliveInterval bounds idle time before an automatic PING.
// Zero disables automatic keepalive.
KeepaliveInterval time.Duration
// KeepaliveMaxPingInterval bounds time between local PINGs while keepalive is enabled.
// Zero disables this extra cap.
KeepaliveMaxPingInterval time.Duration
// KeepaliveTimeout bounds how long a keepalive PING may remain unanswered.
// Zero uses an adaptive default.
KeepaliveTimeout time.Duration
// PingPadding pads local PINGs and recognized PONG replies.
// It also advertises a per-session PingPaddingKey.
PingPadding bool
// PingPaddingMinBytes is the lower PING/PONG padding bound.
// For PING, it includes the fixed 8-byte tag. Zero uses the default.
PingPaddingMinBytes uint64
// PingPaddingMaxBytes is the upper PING/PONG padding bound.
// For PING, it includes the fixed 8-byte tag. Zero uses the default.
PingPaddingMaxBytes uint64
// SessionMemoryCap overrides the tracked-session-memory cap. Zero uses the default.
SessionMemoryCap uint64
// PerStreamQueuedDataHWM overrides the per-stream queued-data high watermark.
// Zero uses the default.
PerStreamQueuedDataHWM uint64
// SessionQueuedDataHWM overrides the session-wide queued-data high watermark.
// Zero uses the default.
SessionQueuedDataHWM uint64
// UrgentQueuedBytesCap overrides the urgent/control lane cap. Zero uses the default.
UrgentQueuedBytesCap uint64
// PendingControlBytesBudget overrides the coalesced control byte budget.
// Zero uses the default.
PendingControlBytesBudget uint64
// PendingPriorityBytesBudget overrides the coalesced advisory byte budget.
// Zero uses the default.
PendingPriorityBytesBudget uint64
// RetainedOpenInfoBytesBudget overrides the retained open_info byte budget.
// Zero uses the default.
RetainedOpenInfoBytesBudget uint64
// RetainedPeerReasonBytesBudget overrides the retained peer reason-text byte budget.
// Zero uses the default.
RetainedPeerReasonBytesBudget uint64
// AggregateLateDataCap overrides aggregate late-data accounting. Zero uses the default.
AggregateLateDataCap uint64
// AcceptBacklogLimit overrides the visible accept backlog count. Zero uses the default.
AcceptBacklogLimit int
// AcceptBacklogBytesLimit overrides visible accept backlog bytes. Zero uses the default.
AcceptBacklogBytesLimit uint64
// TombstoneLimit overrides the retained tombstone count. Zero uses the default.
TombstoneLimit int
// MarkerOnlyUsedStreamLimit overrides retained marker-only used-stream entries.
// Zero uses the derived default.
MarkerOnlyUsedStreamLimit int
// AbuseWindow overrides the local anti-abuse accounting window. Zero uses the default.
AbuseWindow time.Duration
// HiddenAbortChurnWindow overrides hidden abort churn detection. Zero uses the default.
HiddenAbortChurnWindow time.Duration
// HiddenAbortChurnThreshold overrides hidden open-then-abort churn. Zero uses the default.
HiddenAbortChurnThreshold uint32
// VisibleTerminalChurnWindow overrides visible terminal churn detection.
// Zero uses the default.
VisibleTerminalChurnWindow time.Duration
// VisibleTerminalChurnThreshold overrides visible open-then-reset/abort churn.
// Zero uses the default.
VisibleTerminalChurnThreshold uint32
// InboundControlFrameBudget overrides the inbound control-frame window.
// Zero uses the default.
InboundControlFrameBudget uint32
// InboundControlBytesBudget overrides the inbound control-byte window.
// Zero uses the default.
InboundControlBytesBudget uint64
// InboundExtFrameBudget overrides the inbound EXT-frame window. Zero uses the default.
InboundExtFrameBudget uint32
// InboundExtBytesBudget overrides the inbound EXT-byte window. Zero uses the default.
InboundExtBytesBudget uint64
// InboundMixedFrameBudget overrides the mixed control/EXT frame window.
// Zero uses the default.
InboundMixedFrameBudget uint32
// InboundMixedBytesBudget overrides the mixed control/EXT byte window.
// Zero uses the default.
InboundMixedBytesBudget uint64
// NoOpControlFloodThreshold overrides the mixed no-op control threshold.
// Zero uses the default.
NoOpControlFloodThreshold uint32
// NoOpMaxDataFloodThreshold overrides the no-op MAX_DATA threshold.
// Zero uses the default.
NoOpMaxDataFloodThreshold uint32
// NoOpBlockedFloodThreshold overrides the no-op BLOCKED threshold. Zero uses the default.
NoOpBlockedFloodThreshold uint32
// NoOpZeroDataFloodThreshold overrides the zero-length DATA threshold.
// Zero uses the default.
NoOpZeroDataFloodThreshold uint32
// NoOpPriorityUpdateFloodThreshold overrides the no-op PRIORITY_UPDATE threshold.
// Zero uses the default.
NoOpPriorityUpdateFloodThreshold uint32
// GroupRebucketChurnThreshold overrides repeated stream_group rebucketing.
// Zero uses the default.
GroupRebucketChurnThreshold uint32
// InboundPingFloodThreshold overrides the inbound PING flood threshold.
// Zero uses the default.
InboundPingFloodThreshold uint32
// StopSendingGracefulDrainWindow bounds graceful drain after peer STOP_SENDING.
// Zero uses the default.
StopSendingGracefulDrainWindow time.Duration
// StopSendingGracefulTailCap bounds DATA|FIN tail after peer STOP_SENDING.
// Zero uses the default.
StopSendingGracefulTailCap uint64
// GracefulCloseDrainTimeout bounds Close waiting for graceful drain.
// Zero uses the default.
GracefulCloseDrainTimeout time.Duration
// EventHandler receives lightweight connection/stream lifecycle notifications.
EventHandler EventHandler
}
Config controls session establishment and runtime behavior.
Prefer starting from DefaultConfig(). The zero value is not the default: Role zero is RoleInitiator, and defaults also enable padding and keepalive.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a copy of the process-wide default configuration template.
func (Config) LocalPreface ¶
type ConformanceSuite ¶
type ConformanceSuite string
ConformanceSuite identifies one repository-defined local conformance suite selection bucket derived from CONFORMANCE.md.
const ( SuiteCoreWireInteroperability ConformanceSuite = "core-wire-interoperability" SuiteInvalidInputHandling ConformanceSuite = "invalid-input-handling" SuiteExtensionTolerance ConformanceSuite = "extension-tolerance" SuiteCoreStreamLifecycle ConformanceSuite = "core-stream-lifecycle" SuiteCoreFlowControl ConformanceSuite = "core-flow-control" SuiteCoreSessionLifecycle ConformanceSuite = "core-session-lifecycle" SuiteOpenMetadata ConformanceSuite = "open_metadata" SuitePriorityUpdate ConformanceSuite = "priority_update" SuitePriorityHintsAndStreamGroups ConformanceSuite = "priority-hints-and-stream-groups" SuiteV1ProfileCompatibility ConformanceSuite = "v1-profile-compatibility" SuiteAPISemanticsProfile ConformanceSuite = "api-semantics-profile" SuiteStreamAdapterProfile ConformanceSuite = "stream-adapter-profile" SuiteReferenceProfileClaimGate ConformanceSuite = "reference-profile-claim-gate" SuiteReferenceQualityBehaviors ConformanceSuite = "reference-quality-behaviors" )
func CoreModuleTargetSuites ¶ added in v1.1.0
func CoreModuleTargetSuites() []ConformanceSuite
CoreModuleTargetSuites returns the ordered union of conformance suites needed to substantiate the core zmux module's target claims and profiles. The returned slice is a copy and may be modified by the caller.
func KnownConformanceSuites ¶
func KnownConformanceSuites() []ConformanceSuite
KnownConformanceSuites returns the repository-defined local conformance suite selection buckets recognized by this package.
func (ConformanceSuite) Valid ¶
func (s ConformanceSuite) Valid() bool
Valid reports whether the suite matches one of the repository-defined local conformance suite selection buckets.
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is the native zmux session implementation.
func Client ¶
func Client(conn io.ReadWriteCloser, cfg *Config) (*Conn, error)
Client establishes a native initiator session.
func ClientIO ¶ added in v1.1.2
ClientIO establishes a native initiator session on separate reader and writer halves.
func New ¶
func New(conn io.ReadWriteCloser, cfg *Config) (*Conn, error)
New establishes a native zmux session.
func NewIO ¶ added in v1.1.2
NewIO establishes a native zmux session on separate reader and writer halves.
func Server ¶
func Server(conn io.ReadWriteCloser, cfg *Config) (*Conn, error)
Server establishes a native responder session.
func ServerIO ¶ added in v1.1.2
ServerIO establishes a native responder session on separate reader and writer halves.
func (*Conn) AcceptStream ¶
func (c *Conn) AcceptStream(ctx context.Context) (NativeStream, error)
func (*Conn) AcceptUniStream ¶
func (c *Conn) AcceptUniStream(ctx context.Context) (NativeRecvStream, error)
func (*Conn) CloseWithError ¶ added in v1.0.4
func (*Conn) GoAwayWithError ¶
func (*Conn) LocalPreface ¶
func (*Conn) Negotiated ¶
func (c *Conn) Negotiated() Negotiated
func (*Conn) OpenAndSend ¶
func (*Conn) OpenAndSendWithOptions ¶
func (c *Conn) OpenAndSendWithOptions(ctx context.Context, opts OpenOptions, p []byte) (NativeStream, int, error)
func (*Conn) OpenStream ¶
func (c *Conn) OpenStream(ctx context.Context) (NativeStream, error)
func (*Conn) OpenStreamWithOptions ¶
func (c *Conn) OpenStreamWithOptions(ctx context.Context, opts OpenOptions) (NativeStream, error)
func (*Conn) OpenUniAndSend ¶
func (*Conn) OpenUniAndSendWithOptions ¶
func (c *Conn) OpenUniAndSendWithOptions(ctx context.Context, opts OpenOptions, p []byte) (NativeSendStream, int, error)
func (*Conn) OpenUniStream ¶
func (c *Conn) OpenUniStream(ctx context.Context) (NativeSendStream, error)
func (*Conn) OpenUniStreamWithOptions ¶
func (c *Conn) OpenUniStreamWithOptions(ctx context.Context, opts OpenOptions) (NativeSendStream, error)
func (*Conn) PeerCloseError ¶
func (c *Conn) PeerCloseError() *ApplicationError
PeerCloseError returns the last peer CLOSE error, if any.
func (*Conn) PeerGoAwayError ¶
func (c *Conn) PeerGoAwayError() *ApplicationError
PeerGoAwayError returns the last peer GOAWAY error, if any.
func (*Conn) PeerPreface ¶
func (*Conn) State ¶
func (c *Conn) State() SessionState
State returns the current public session state.
func (*Conn) Stats ¶
func (c *Conn) Stats() SessionStats
type DiagnosticStats ¶
type DiagnosticStats struct {
DroppedPriorityUpdates uint64
DroppedLocalPriorityUpdates uint64
LateDataAfterCloseRead uint64
LateDataAfterReset uint64
LateDataAfterAbort uint64
CoalescedTerminal uint64
SupersededTerminal uint64
SkippedCloseOnDeadIO uint64
CloseFrameAdmissionTimeouts uint64
CloseFrameFlushTimeouts uint64
CloseFrameFlushErrors uint64
ProtocolBacklogBlocked uint64
MarkerOnlyRangeCount int
}
DiagnosticStats reports ingress, drop, and late-data counters.
type Direction ¶
type Direction uint8
Direction identifies which stream direction the error applies to.
type DuplexByteStream ¶
DuplexByteStream is the minimal transport shape accepted by session constructors.
type EXTSubtype ¶
type EXTSubtype = wire.EXTSubtype
type Error ¶
type Error struct {
Scope Scope
Operation Operation
Source Source
WireCode uint64
ReasonText string
Direction Direction
TerminationKind TerminationKind
Err error
}
Error is the structured error wrapper returned by public APIs.
func AsStructuredError ¶
AsStructuredError returns the structured error wrapper when present.
type ErrorCode ¶
func ErrorCodeOf ¶
ErrorCodeOf returns the wire or application error code when one is present.
type Event ¶
type Event struct {
Type EventType
SessionState SessionState
StreamID uint64
Stream Stream
Local bool
Bidi bool
Time time.Time
Err error
ApplicationVisible bool
}
Event is delivered to EventHandler.
type EventHandler ¶
type EventHandler func(Event)
EventHandler receives opt-in stream and session events.
type FlushStats ¶
FlushStats reports the most recent writer flush.
type HiddenStats ¶
type HiddenStats struct {
Refused uint64
Reaped uint64
UnreadBytesDiscarded uint64
Retained int
SoftCap int
HardCap int
AtSoftCap bool
AtHardCap bool
}
HiddenStats reports hidden-stream counters and limits.
type ImplementationProfile ¶
type ImplementationProfile string
ImplementationProfile identifies one repository-defined implementation profile name from the zmux document set.
const ( ProfileV1 ImplementationProfile = "zmux-v1" ProfileReferenceV1 ImplementationProfile = "zmux-reference-profile-v1" )
func CoreModuleTargetImplementationProfiles ¶ added in v1.1.0
func CoreModuleTargetImplementationProfiles() []ImplementationProfile
CoreModuleTargetImplementationProfiles returns the repository-defined implementation profiles targeted by the core zmux module. The returned slice is a copy and may be modified by the caller.
func KnownImplementationProfiles ¶
func KnownImplementationProfiles() []ImplementationProfile
KnownImplementationProfiles returns the repository-defined implementation profile names recognized by this package. The returned slice is a copy and may be modified by the caller.
func (ImplementationProfile) AcceptanceChecklist ¶
func (p ImplementationProfile) AcceptanceChecklist() []string
AcceptanceChecklist returns the repository-defined minimum acceptance checklist for the implementation profile. The returned slice is a copy and may be modified by the caller.
func (ImplementationProfile) Claims ¶
func (p ImplementationProfile) Claims() []Claim
Claims returns the repository-defined claim bundle associated with the given implementation profile. The returned slice is a copy and may be modified by the caller.
func (ImplementationProfile) ReleaseCertificationGate ¶
func (p ImplementationProfile) ReleaseCertificationGate() []ConformanceSuite
ReleaseCertificationGate returns the repository-defined pass/fail local suite selection gate for the implementation profile.
func (ImplementationProfile) RequiredConformanceSuites ¶
func (p ImplementationProfile) RequiredConformanceSuites() []ConformanceSuite
RequiredConformanceSuites returns the repository-defined local suite selection buckets needed to substantiate the implementation profile.
func (ImplementationProfile) Valid ¶
func (p ImplementationProfile) Valid() bool
Valid reports whether the implementation profile matches one of the repository-defined implementation-profile names in the current zmux document set.
type JoinedConn ¶
type JoinedConn struct {
// contains filtered or unexported fields
}
JoinedConn adapts independent read and write halves into a net.Conn.
Either half may be nil. PauseRead and PauseWrite detach ownership until the returned handle resumes the half.
func JoinConn ¶
func JoinConn(read ReadHalf, write WriteHalf) *JoinedConn
JoinConn adapts one read half plus one write half into a net.Conn-compatible wrapper. Either half may be nil.
func JoinIO ¶ added in v1.1.2
func JoinIO(reader io.Reader, writer io.Writer) *JoinedConn
JoinIO adapts ordinary Go I/O halves into a net.Conn-compatible JoinedConn.
Either half may be nil, matching JoinConn. The returned connection forwards deadline and address calls when the underlying half exposes compatible methods such as SetReadDeadline, SetWriteDeadline, LocalAddr, or RemoteAddr. Plain io.Reader/io.Writer values that do not expose deadline methods return errors.ErrUnsupported from deadline setters.
func (*JoinedConn) Close ¶
func (c *JoinedConn) Close() error
Close closes the currently attached halves and wakes all blocked operations. Halves that were already detached through PauseRead or PauseWrite remain caller-owned and are not closed by JoinedConn.
func (*JoinedConn) CloseRead ¶
func (c *JoinedConn) CloseRead() error
CloseRead closes the currently attached read half. If no read half is attached, CloseRead is a no-op.
func (*JoinedConn) CloseWrite ¶
func (c *JoinedConn) CloseWrite() error
CloseWrite closes the currently attached write half. If no write half is attached, CloseWrite is a no-op.
func (*JoinedConn) LocalAddr ¶
func (c *JoinedConn) LocalAddr() net.Addr
func (*JoinedConn) PauseRead ¶
func (c *JoinedConn) PauseRead(ctx context.Context) (*PausedReadHalf, error)
PauseRead waits for the read side to become quiescent, detaches the current read half, and returns a handle that owns it. The returned handle may stage a replacement half before Resume reattaches it.
func (*JoinedConn) PauseWrite ¶
func (c *JoinedConn) PauseWrite(ctx context.Context) (*PausedWriteHalf, error)
PauseWrite waits for the write side to become quiescent, detaches the current write half, and returns a handle that owns it. The returned handle may stage a replacement half before Resume reattaches it.
func (*JoinedConn) ReadHalf ¶
func (c *JoinedConn) ReadHalf() ReadHalf
ReadHalf returns the currently attached read half. It returns nil while the read side is paused, detached, or absent.
func (*JoinedConn) RemoteAddr ¶
func (c *JoinedConn) RemoteAddr() net.Addr
func (*JoinedConn) SetDeadline ¶
func (c *JoinedConn) SetDeadline(t time.Time) error
func (*JoinedConn) SetReadDeadline ¶
func (c *JoinedConn) SetReadDeadline(t time.Time) error
func (*JoinedConn) SetWriteDeadline ¶
func (c *JoinedConn) SetWriteDeadline(t time.Time) error
func (*JoinedConn) WriteHalf ¶
func (c *JoinedConn) WriteHalf() WriteHalf
WriteHalf returns the currently attached write half. It returns nil while the write side is paused, detached, or absent.
type MetadataUpdate ¶
MetadataUpdate carries post-open advisory metadata changes.
type NativeRecvStream ¶
type NativeRecvStream interface {
RecvStream
OpenedLocally() bool
Bidirectional() bool
ReadClosed() bool
}
NativeRecvStream is the native receive-only stream interface.
type NativeSendStream ¶
type NativeSendStream interface {
SendStream
OpenedLocally() bool
Bidirectional() bool
WriteClosed() bool
}
NativeSendStream is the native send-only stream interface.
type NativeSession ¶ added in v1.0.4
type NativeSession interface {
AcceptStream(ctx context.Context) (NativeStream, error)
AcceptUniStream(ctx context.Context) (NativeRecvStream, error)
OpenStream(ctx context.Context) (NativeStream, error)
OpenUniStream(ctx context.Context) (NativeSendStream, error)
OpenStreamWithOptions(ctx context.Context, opts OpenOptions) (NativeStream, error)
OpenUniStreamWithOptions(ctx context.Context, opts OpenOptions) (NativeSendStream, error)
OpenAndSend(ctx context.Context, p []byte) (NativeStream, int, error)
OpenAndSendWithOptions(ctx context.Context, opts OpenOptions, p []byte) (NativeStream, int, error)
OpenUniAndSend(ctx context.Context, p []byte) (NativeSendStream, int, error)
OpenUniAndSendWithOptions(ctx context.Context, opts OpenOptions, p []byte) (NativeSendStream, int, error)
Close() error
CloseWithError(err error)
Wait(ctx context.Context) error
Closed() bool
State() SessionState
Stats() SessionStats
Ping(ctx context.Context, echo []byte) (time.Duration, error)
GoAway(lastAcceptedBidi, lastAcceptedUni uint64) error
GoAwayWithError(lastAcceptedBidi, lastAcceptedUni, code uint64, reason string) error
PeerGoAwayError() *ApplicationError
PeerCloseError() *ApplicationError
LocalPreface() Preface
PeerPreface() Preface
Negotiated() Negotiated
}
NativeSession is the native zmux session interface.
It repeats open and accept methods with native stream return types because Go does not support covariant interface return types.
type NativeStream ¶
type NativeStream interface {
Stream
OpenedLocally() bool
Bidirectional() bool
ReadClosed() bool
WriteClosed() bool
}
NativeStream is the native bidirectional stream interface.
type Negotiated ¶
type Negotiated = wire.Negotiated
func NegotiatePrefaces ¶
func NegotiatePrefaces(local, peer Preface) (Negotiated, error)
type OpenOptions ¶
OpenOptions carries optional open-time inputs for a new stream.
InitialPriority and InitialGroup may remain local sender-policy hints when the corresponding peer-visible carriage is unavailable. OpenInfo is peer-visible open-time metadata and is rejected if it cannot be carried on the opening frame.
type PausedReadHalf ¶
type PausedReadHalf struct {
// contains filtered or unexported fields
}
PausedReadHalf owns a detached read half until Resume reattaches it.
func (*PausedReadHalf) Current ¶
func (p *PausedReadHalf) Current() ReadHalf
Current returns the read half currently owned by the pause handle.
func (*PausedReadHalf) Resume ¶
func (p *PausedReadHalf) Resume() error
Resume reattaches the staged read half and re-enables upper-layer reads.
func (*PausedReadHalf) Set ¶
func (p *PausedReadHalf) Set(next ReadHalf) ReadHalf
Set stages next as the read half to attach on Resume and returns the previously staged half. Passing nil detaches the read side.
type PausedWriteHalf ¶
type PausedWriteHalf struct {
// contains filtered or unexported fields
}
PausedWriteHalf owns a detached write half until Resume reattaches it.
func (*PausedWriteHalf) Current ¶
func (p *PausedWriteHalf) Current() WriteHalf
Current returns the write half currently owned by the pause handle.
func (*PausedWriteHalf) Resume ¶
func (p *PausedWriteHalf) Resume() error
Resume reattaches the staged write half and re-enables upper-layer writes.
func (*PausedWriteHalf) Set ¶
func (p *PausedWriteHalf) Set(next WriteHalf) WriteHalf
Set stages next as the write half to attach on Resume and returns the previously staged half. Passing nil detaches the write side.
type Preface ¶
func ParsePreface ¶
type PressureStats ¶
type PressureStats struct {
ReceiveBacklog uint64
ReceiveBacklogHigh bool
AggregateLateData uint64
AggregateLateDataAtCap bool
RetainedState uint64
RetainedBuckets RetainedStateBreakdown
RetainedOpenInfo uint64
RetainedPeerReasons uint64
OutstandingPingBytes uint64
TrackedBuffered uint64
TrackedBufferedLimit uint64
TrackedBufferedHigh bool
TrackedBufferedAtCap bool
OrdinaryQueued uint64
AdvisoryQueued uint64
UrgentQueued uint64
PendingControl uint64
PendingAdvisory uint64
PreparedAdvisory uint64
PendingTerminal uint64
PendingTerminalCount int
PendingProtocolJobs int
}
PressureStats reports queue, memory, and retention pressure.
type ProgressStats ¶
type ProgressStats struct {
TransportProgressAt time.Time
MuxControlProgressAt time.Time
StreamProgressAt time.Time
ApplicationProgressAt time.Time
}
ProgressStats reports recent transport, mux, stream, and app activity times.
type ProvisionalStats ¶
type ProvisionalStats struct {
Bidi int
Uni int
SoftCap int
HardCap int
BidiAtSoft bool
UniAtSoft bool
BidiAtHard bool
UniAtHard bool
Limited uint64
Expired uint64
}
ProvisionalStats reports provisional-open counts and limits.
type QueueStats ¶
QueueStats reports writer queue depths.
type ReadHalf ¶
type ReadHalf interface {
io.Reader
CloseRead() error
SetReadDeadline(time.Time) error
LocalAddr() net.Addr
RemoteAddr() net.Addr
}
ReadHalf is the minimal directional read-side contract required by JoinedConn.
type ReasonStats ¶
type ReasonStats struct {
Reset map[uint64]uint64
ResetOverflow uint64
Abort map[uint64]uint64
AbortOverflow uint64
}
ReasonStats counts observed reset and abort codes. Overflow counters count events folded after the distinct-code map cap is reached.
type RecvStream ¶
type RecvStream interface {
io.Reader
io.Closer
StreamID() uint64
OpenInfo() []byte
LocalAddr() net.Addr
RemoteAddr() net.Addr
Metadata() StreamMetadata
CloseRead() error
CancelRead(code uint64) error
CloseWithError(code uint64, reason string) error
SetDeadline(t time.Time) error
SetReadDeadline(t time.Time) error
}
RecvStream is the stable receive-only stream interface.
type RetainedBucketStats ¶
RetainedBucketStats reports retained item and byte counts.
type RetainedStateBreakdown ¶
type RetainedStateBreakdown struct {
HiddenControl RetainedBucketStats
AcceptBacklog RetainedBucketStats
Provisionals RetainedBucketStats
VisibleTombstone RetainedBucketStats
MarkerOnly RetainedBucketStats
}
RetainedStateBreakdown reports retained bytes by category.
func (RetainedStateBreakdown) TotalBytes ¶
func (r RetainedStateBreakdown) TotalBytes() uint64
type SchedulerHint ¶
type SchedulerHint = wire.SchedulerHint
func SchedulerHintFromCode ¶ added in v1.1.0
func SchedulerHintFromCode(code uint64) SchedulerHint
type SendStream ¶
type SendStream interface {
io.Writer
io.Closer
StreamID() uint64
OpenInfo() []byte
LocalAddr() net.Addr
RemoteAddr() net.Addr
Metadata() StreamMetadata
UpdateMetadata(update MetadataUpdate) error
WriteFinal(p []byte) (int, error)
WritevFinal(parts ...[]byte) (int, error)
CloseWrite() error
CancelWrite(code uint64) error
CloseWithError(code uint64, reason string) error
SetDeadline(t time.Time) error
SetWriteDeadline(t time.Time) error
}
SendStream is the stable send-only stream interface.
type Session ¶
type Session interface {
io.Closer
AcceptStream(ctx context.Context) (Stream, error)
AcceptUniStream(ctx context.Context) (RecvStream, error)
OpenStream(ctx context.Context) (Stream, error)
OpenUniStream(ctx context.Context) (SendStream, error)
OpenStreamWithOptions(ctx context.Context, opts OpenOptions) (Stream, error)
OpenUniStreamWithOptions(ctx context.Context, opts OpenOptions) (SendStream, error)
OpenAndSend(ctx context.Context, p []byte) (Stream, int, error)
OpenAndSendWithOptions(ctx context.Context, opts OpenOptions, p []byte) (Stream, int, error)
OpenUniAndSend(ctx context.Context, p []byte) (SendStream, int, error)
OpenUniAndSendWithOptions(ctx context.Context, opts OpenOptions, p []byte) (SendStream, int, error)
CloseWithError(err error)
Wait(ctx context.Context) error
Closed() bool
State() SessionState
Stats() SessionStats
}
Session is the stable session interface used by native zmux and adapters.
func ClientIOSession ¶ added in v1.1.2
ClientIOSession returns a stable initiator Session backed by native zmux on separate reader and writer halves.
func ClientSession ¶
func ClientSession(conn io.ReadWriteCloser, cfg *Config) (Session, error)
ClientSession returns a stable initiator Session backed by native zmux.
func NewIOSession ¶ added in v1.1.2
NewIOSession returns a stable Session backed by native zmux on separate reader and writer halves.
func NewSession ¶
func NewSession(conn io.ReadWriteCloser, cfg *Config) (Session, error)
NewSession returns a stable Session backed by native zmux.
func ServerIOSession ¶ added in v1.1.2
ServerIOSession returns a stable responder Session backed by native zmux on separate reader and writer halves.
func ServerSession ¶
func ServerSession(conn io.ReadWriteCloser, cfg *Config) (Session, error)
ServerSession returns a stable responder Session backed by native zmux.
type SessionState ¶
type SessionState uint8
SessionState is the public session lifecycle state.
const ( SessionStateInvalid SessionState = iota SessionStateReady SessionStateDraining SessionStateClosing SessionStateClosed SessionStateFailed )
func (SessionState) String ¶
func (s SessionState) String() string
func (SessionState) Terminal ¶
func (s SessionState) Terminal() bool
Terminal reports whether s is final.
func (SessionState) Valid ¶
func (s SessionState) Valid() bool
Valid reports whether s is a defined public session state.
type SessionStats ¶
type SessionStats struct {
State SessionState
KeepaliveInterval time.Duration
KeepaliveMaxPingInterval time.Duration
KeepaliveTimeout time.Duration
PingOutstanding bool
PingStalled bool
Progress ProgressStats
LastInboundFrameAt time.Time
LastControlProgress time.Time
LastTransportWrite time.Time
LastStreamProgress time.Time
LastAppProgress time.Time
LastPingSentAt time.Time
LastPongAt time.Time
LastPingRTT time.Duration
ActiveStreams ActiveStreamStats
Queues QueueStats
Flush FlushStats
BlockedWriteTotal time.Duration
LastOpenLatency time.Duration
Pressure PressureStats
Hidden HiddenStats
AcceptBacklog AcceptBacklogStats
Provisionals ProvisionalStats
Reasons ReasonStats
Diagnostics DiagnosticStats
}
SessionStats is a snapshot of session state and runtime counters.
type Settings ¶
func DefaultSettings ¶
func DefaultSettings() Settings
type Stream ¶
type Stream interface {
net.Conn
StreamID() uint64
OpenInfo() []byte
Metadata() StreamMetadata
UpdateMetadata(update MetadataUpdate) error
WriteFinal(p []byte) (int, error)
WritevFinal(parts ...[]byte) (int, error)
CloseRead() error
CancelRead(code uint64) error
CloseWrite() error
CancelWrite(code uint64) error
CloseWithError(code uint64, reason string) error
}
Stream is the stable bidirectional stream interface.
type StreamMetadata ¶
StreamMetadata is the advisory metadata currently known for a stream.
type StreamMetadataType ¶
type StreamMetadataType = wire.StreamMetadataType
type TerminationKind ¶
type TerminationKind uint8
TerminationKind identifies how the operation terminated.
const ( TerminationUnknown TerminationKind = iota TerminationGraceful TerminationStopped TerminationReset TerminationAbort TerminationSessionTermination )
func (TerminationKind) String ¶
func (k TerminationKind) String() string
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
adapter
|
|
|
quicmux
module
|
|
|
internal
|
|
|
runtime
Package runtime contains internal scheduling, queueing, and policy helpers.
|
Package runtime contains internal scheduling, queueing, and policy helpers. |
|
state
Package state contains internal stream and session state helpers.
|
Package state contains internal stream and session state helpers. |
|
wire
Package wire contains internal codecs, framing, TLV, and preface helpers.
|
Package wire contains internal codecs, framing, TLV, and preface helpers. |
|
seal
module
|
|
|
zmuxh3
module
|
|
|
zmuxquic
module
|
|
|
zmuxws
module
|