Documentation
¶
Overview ¶
Package zmux implements the zmux v1 single-connection stream multiplexer.
The package exposes repository-default Session, Stream, SendStream, and RecvStream interfaces for opening, accepting, reading, writing, and closing multiplexed streams over a single transport connection.
The root package is the supported integration surface. Wire codec logic, protocol-state helpers, and repository-default runtime policy remain in shallow internal packages:
- internal/wire
- internal/state
- internal/runtime
Library users should treat those internal packages as implementation details rather than import contracts.
Index ¶
- Constants
- Variables
- func AppendTLV(dst []byte, typ uint64, value []byte) ([]byte, error)
- func AppendVarint(dst []byte, v uint64) ([]byte, error)
- 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 VarintLen(v uint64) (int, error)
- type AcceptBacklogStats
- type ApplicationError
- type Capabilities
- type Claim
- type Config
- type ConformanceSuite
- type Conn
- func (c *Conn) Abort(err 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) 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 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
- 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 )
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") ErrEmptyMetadataUpdate = errors.New("zmux: metadata update has no fields") ErrKeepaliveTimeout = errors.New("zmux: keepalive timeout") )
Functions ¶
func EncodeVarint ¶
func IsErrorCode ¶
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.
Types ¶
type AcceptBacklogStats ¶
type ApplicationError ¶
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 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
KeepaliveInterval time.Duration
KeepaliveTimeout time.Duration
// SessionMemoryCap overrides the repository-default tracked-session-memory
// hard cap. Zero uses the repository default.
SessionMemoryCap uint64
// PerStreamQueuedDataHWM overrides the repository-default per-stream
// ordinary queued-data high watermark. Zero uses the repository default.
PerStreamQueuedDataHWM uint64
// SessionQueuedDataHWM overrides the repository-default session-wide
// ordinary queued-data high watermark. Zero uses the repository default.
SessionQueuedDataHWM uint64
// UrgentQueuedBytesCap overrides the repository-default urgent/control lane
// hard cap. Zero uses the repository default.
UrgentQueuedBytesCap uint64
// PendingControlBytesBudget overrides the repository-default coalesced
// pending control-plane byte budget. Zero uses the repository default.
PendingControlBytesBudget uint64
// PendingPriorityBytesBudget overrides the repository-default coalesced
// pending advisory byte budget. Zero uses the repository default.
PendingPriorityBytesBudget uint64
// RetainedOpenInfoBytesBudget overrides the repository-default retained
// open_info byte budget. Zero uses the repository default.
RetainedOpenInfoBytesBudget uint64
// RetainedPeerReasonBytesBudget overrides the repository-default retained
// peer reason-text byte budget. Zero uses the repository default.
RetainedPeerReasonBytesBudget uint64
// AggregateLateDataCap overrides the repository-default aggregate late-data
// accounting cap. Zero uses the repository default.
AggregateLateDataCap uint64
// AcceptBacklogLimit overrides the repository-default visible accept backlog
// count cap. Zero uses the repository default.
AcceptBacklogLimit int
// AcceptBacklogBytesLimit overrides the repository-default visible accept
// backlog byte cap. Zero uses the repository default.
AcceptBacklogBytesLimit uint64
// TombstoneLimit overrides the repository-default retained tombstone count
// limit. Zero uses the repository default.
TombstoneLimit int
// MarkerOnlyUsedStreamLimit overrides the repository-default maximum count
// of retained marker-only used-stream entries after tombstones have been
// compacted or reaped. Zero uses the repository-default derived cap.
MarkerOnlyUsedStreamLimit int
// AbuseWindow overrides the repository-default local anti-abuse accounting
// window. Zero uses the repository default.
AbuseWindow time.Duration
// HiddenAbortChurnWindow overrides the repository-default hidden abort churn
// detection window. Zero uses the repository default.
HiddenAbortChurnWindow time.Duration
// HiddenAbortChurnThreshold overrides the repository-default hidden
// open-then-abort churn threshold. Zero uses the repository default.
HiddenAbortChurnThreshold uint32
// VisibleTerminalChurnWindow overrides the repository-default visible churn
// detection window. Zero uses the repository default.
VisibleTerminalChurnWindow time.Duration
// VisibleTerminalChurnThreshold overrides the repository-default visible
// open-then-reset/abort churn threshold. Zero uses the repository default.
VisibleTerminalChurnThreshold uint32
// InboundControlFrameBudget overrides the repository-default inbound
// control-frame rolling window budget. Zero uses the repository default.
InboundControlFrameBudget uint32
// InboundControlBytesBudget overrides the repository-default inbound
// control-byte rolling window budget. Zero uses the repository default.
InboundControlBytesBudget uint64
// InboundExtFrameBudget overrides the repository-default inbound EXT-frame
// rolling window budget. Zero uses the repository default.
InboundExtFrameBudget uint32
// InboundExtBytesBudget overrides the repository-default inbound EXT-byte
// rolling window budget. Zero uses the repository default.
InboundExtBytesBudget uint64
// InboundMixedFrameBudget overrides the repository-default mixed
// control/EXT frame rolling window budget. Zero uses the repository default.
InboundMixedFrameBudget uint32
// InboundMixedBytesBudget overrides the repository-default mixed
// control/EXT byte rolling window budget. Zero uses the repository default.
InboundMixedBytesBudget uint64
// NoOpControlFloodThreshold overrides the repository-default mixed no-op
// control threshold. Zero uses the repository default.
NoOpControlFloodThreshold uint32
// NoOpMaxDataFloodThreshold overrides the repository-default no-op MAX_DATA
// threshold. Zero uses the repository default.
NoOpMaxDataFloodThreshold uint32
// NoOpBlockedFloodThreshold overrides the repository-default no-op BLOCKED
// threshold. Zero uses the repository default.
NoOpBlockedFloodThreshold uint32
// NoOpZeroDataFloodThreshold overrides the repository-default zero-length
// DATA threshold. Zero uses the repository default.
NoOpZeroDataFloodThreshold uint32
// NoOpPriorityUpdateFloodThreshold overrides the repository-default no-op
// PRIORITY_UPDATE threshold. Zero uses the repository default.
NoOpPriorityUpdateFloodThreshold uint32
// GroupRebucketChurnThreshold overrides the repository-default repeated
// effective stream_group rebucketing threshold within the local
// anti-abuse window when the negotiated scheduler baseline is group_fair.
// Zero uses the repository default.
GroupRebucketChurnThreshold uint32
// InboundPingFloodThreshold overrides the repository-default inbound PING
// flood threshold. Zero uses the repository default.
InboundPingFloodThreshold uint32
// StopSendingGracefulDrainWindow overrides the repository-default bounded
// graceful-drain admission window used after peer STOP_SENDING before
// falling back to RESET(CANCELLED). Zero uses the repository default.
StopSendingGracefulDrainWindow time.Duration
// StopSendingGracefulTailCap overrides the repository-default maximum
// unavoidable tail, in bytes, that may still converge via DATA|FIN after
// peer STOP_SENDING. Zero uses the repository default.
StopSendingGracefulTailCap uint64
// EventHandler receives lightweight connection/stream lifecycle notifications.
EventHandler EventHandler
}
func DefaultConfig ¶
func DefaultConfig() *Config
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" SuiteCoreProfileCompatibility ConformanceSuite = "core-profile-compatibility" SuiteAPISemanticsProfile ConformanceSuite = "api-semantics-profile" SuiteStreamAdapterProfile ConformanceSuite = "stream-adapter-profile" SuiteReferenceProfileClaimGate ConformanceSuite = "reference-profile-claim-gate" SuiteReferenceQualityBehaviors ConformanceSuite = "reference-quality-behaviors" )
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
}
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) Closed ¶
Closed reports whether the session has terminated and can no longer be used for application-visible operations.
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 CLOSE payload from the peer, if any.
It does not alter session state. The returned value is a copy so callers can inspect code and reason safely without mutating connection internals.
func (*Conn) PeerGoAwayError ¶
func (c *Conn) PeerGoAwayError() *ApplicationError
PeerGoAwayError returns the last GOAWAY payload from the peer, if any.
It does not alter session state. The returned value is a copy so callers can inspect code and reason safely without mutating connection internals.
func (*Conn) PeerPreface ¶
func (*Conn) State ¶
func (c *Conn) State() SessionState
State returns the current public lifecycle state of the session.
func (*Conn) Stats ¶
func (c *Conn) Stats() SessionStats
type DiagnosticStats ¶
type DiagnosticStats struct {
DroppedPriorityUpdates uint64
LateDataAfterCloseRead uint64
LateDataAfterReset uint64
LateDataAfterAbort uint64
CoalescedTerminal uint64
SupersededTerminal uint64
SkippedCloseOnDeadIO uint64
ProtocolBacklogClose uint64
}
DiagnosticStats exposes repository-default ingress/drop counters. Late-data counters are absorbed application-byte totals.
type DuplexByteStream ¶
DuplexByteStream is the minimal underlying transport shape expected by the current 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 repository-default structured local error shape.
It wraps the underlying exported sentinel or ApplicationError so errors.Is/errors.As continue to work through the structured repository error.
func AsStructuredError ¶
type ErrorCode ¶
func ErrorCodeOf ¶
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 the payload published to user-defined handlers.
type EventHandler ¶
type EventHandler func(Event)
EventHandler receives opt-in lifecycle notifications when a connection registers notable stream/session events. Callers should keep handlers fast. Callbacks execute without holding internal locks, but they are invoked synchronously when a handler is configured.
type EventType ¶
type EventType int
EventType identifies the kind of lifecycle event.
const ( // EventStreamOpened is emitted when a local stream is given a stream ID and // becomes commit-visible for on-wire operations. // The event is emitted once per stream when local stream metadata is // successfully committed for the first time, including commit attempts via // Write, CloseWrite, CloseRead, and opening-terminal CloseWithError/Abort // paths. EventStreamOpened EventType = iota + 1 // EventStreamAccepted is emitted when a peer-opened stream is returned from // AcceptStream / AcceptUniStream. EventStreamAccepted // EventSessionClosed is emitted when the session terminates. EventSessionClosed )
type FlushStats ¶
type HiddenStats ¶
type ImplementationProfile ¶
type ImplementationProfile string
ImplementationProfile identifies one repository-defined implementation profile name from the zmux document set.
const ( ProfileCoreV1 ImplementationProfile = "zmux-core-v1" ProfileFullV1 ImplementationProfile = "zmux-full-v1" ProfileReferenceV1 ImplementationProfile = "zmux-reference-profile-v1" )
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 an independent read half plus write half into a net.Conn.
Either half may be nil. A nil read half makes Read return ErrStreamNotReadable. A nil write half makes Write return ErrStreamNotWritable.
Directional pause operations hand ownership of the currently attached half to the caller. While paused, upper-layer operations in that direction block until the handle resumes or the joined-level deadline/close wakes them. Close only closes halves that are still attached at the time Close runs; detached halves remain caller-owned.
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 (*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 updates for a stream.
Only Priority and Group have standardized update semantics in zmux v1. Open-time opaque metadata remains carried only through OPEN_METADATA.
type NativeRecvStream ¶
type NativeRecvStream = nativeRecvStream
NativeRecvStream is the concrete repository-default receive-only stream type returned by the native *Conn API.
type NativeSendStream ¶
type NativeSendStream = nativeSendStream
NativeSendStream is the concrete repository-default send-only stream type returned by the native *Conn API.
type NativeStream ¶
type NativeStream = nativeStream
NativeStream is the concrete repository-default bidirectional stream type returned by the native *Conn API.
type Negotiated ¶
type Negotiated = wire.Negotiated
func NegotiatePrefaces ¶
func NegotiatePrefaces(local, peer Preface) (Negotiated, error)
type OpenOptions ¶
OpenOptions carries optional repository-default 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
}
type ProgressStats ¶
type ProgressStats struct {
TransportProgressAt time.Time
MuxControlProgressAt time.Time
StreamProgressAt time.Time
ApplicationProgressAt time.Time
}
ProgressStats is a read-only snapshot of the repository-default liveness progress buckets described in IMPLEMENTATION.md.
type ProvisionalStats ¶
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 RecvStream ¶
type RecvStream interface {
io.Reader
io.Closer
StreamID() uint64
OpenInfo() []byte
LocalAddr() net.Addr
RemoteAddr() net.Addr
Metadata() StreamMetadata
CloseRead() error
CloseReadWithCode(code uint64) error
Abort() error
AbortWithError(err error) error
AbortWithErrorCode(code uint64, reason string) error
SetDeadline(t time.Time) error
SetReadDeadline(t time.Time) error
}
RecvStream defines the repository-default receive-only stream surface.
type RetainedBucketStats ¶
type RetainedStateBreakdown ¶
type RetainedStateBreakdown struct {
HiddenControl RetainedBucketStats
AcceptBacklog RetainedBucketStats
Provisionals RetainedBucketStats
VisibleTombstone RetainedBucketStats
MarkerOnly RetainedBucketStats
}
func (RetainedStateBreakdown) TotalBytes ¶
func (r RetainedStateBreakdown) TotalBytes() uint64
type SchedulerHint ¶
type SchedulerHint = wire.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
Reset(code uint64) error
ResetWithReason(code uint64, reason string) error
Abort() error
AbortWithError(err error) error
AbortWithErrorCode(code uint64, reason string) error
SetDeadline(t time.Time) error
SetWriteDeadline(t time.Time) error
}
SendStream defines the repository-default send-only stream surface.
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)
Wait(ctx context.Context) error
Closed() bool
State() SessionState
Stats() SessionStats
}
Session defines the repository-default session surface used by native zmux and transport adapters.
func ClientSession ¶
func ClientSession(conn io.ReadWriteCloser, cfg *Config) (Session, error)
ClientSession establishes an initiator-native session and returns it through the stable Session interface.
func NewSession ¶
func NewSession(conn io.ReadWriteCloser, cfg *Config) (Session, error)
NewSession establishes a native zmux session and returns it through the stable Session interface.
func ServerSession ¶
func ServerSession(conn io.ReadWriteCloser, cfg *Config) (Session, error)
ServerSession establishes a responder-native session and returns it through the stable Session interface.
type SessionState ¶
type SessionState uint8
SessionState is the public lifecycle state of a zmux session.
Current public constructors complete establishment before returning, so ordinary callers will observe sessions beginning in SessionStateReady rather than an establishing 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 a final session state.
func (SessionState) Valid ¶
func (s SessionState) Valid() bool
Valid reports whether s is one of the defined public session states.
type SessionStats ¶
type SessionStats struct {
State SessionState
KeepaliveInterval 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
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 read-only snapshot of repository-default liveness and local diagnostic 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
CloseReadWithCode(code uint64) error
CloseWrite() error
Reset(code uint64) error
ResetWithReason(code uint64, reason string) error
Abort() error
AbortWithError(err error) error
AbortWithErrorCode(code uint64, reason string) error
}
Stream defines the repository-default bidirectional stream surface.
Native zmux implements every method directly. Adapters may provide a best-effort mapping for methods that don't have a protocol-native equivalent.
type StreamMetadata ¶
StreamMetadata exposes the repository-default advisory metadata currently known for a stream.
Priority defaults to 0. Group is nil when the stream has no explicit group assignment. OpenInfo is the opener's opaque byte string when present.
type StreamMetadataType ¶
type StreamMetadataType = wire.StreamMetadataType
type TerminationKind ¶
type TerminationKind uint8
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, batching, and repository-default runtime policy helpers used by the public zmux package.
|
Package runtime contains internal scheduling, queueing, batching, and repository-default runtime policy helpers used by the public zmux package. |
|
state
Package state contains internal protocol-state helpers used by the public zmux package.
|
Package state contains internal protocol-state helpers used by the public zmux package. |
|
wire
Package wire contains internal codec, registry, framing, TLV, and preface helpers used by the public zmux package.
|
Package wire contains internal codec, registry, framing, TLV, and preface helpers used by the public zmux package. |
|
seal
module
|
|
|
zmuxh3
module
|
|
|
zmuxquic
module
|
|
|
zmuxws
module
|