quicstream

package
v0.0.0-...-0fc3877 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2026 License: GPL-3.0 Imports: 14 Imported by: 7

Documentation

Overview

Package quicstream supports stream, based on quic.

Index

Constants

This section is empty.

Variables

View Source
var (
	ConnectionIDContextKey = util.ContextKey("connection_id")
	StreamIDContextKey     = util.ContextKey("stream_id")
)
View Source
var ErrHandlerNotFound = util.NewIDError("handler not found")
View Source
var ErrNetwork = util.NewIDError("network error")
View Source
var ErrOpenStream = util.NewIDError("open stream")
View Source
var MetricsCollectorContextKey = util.ContextKey("network-metrics-collector")

MetricsCollectorContextKey is used to propagate the optional metrics collector through contexts that are shared by the networking stack.

View Source
var PrefixHandlerPrefixContextKey = util.ContextKey("prefix-handler-prefix")

Functions

func ConnectionLoggerFromContext

func ConnectionLoggerFromContext(ctx context.Context, log *zerolog.Logger) zerolog.Logger

func IsSeriousError

func IsSeriousError(err error) bool

func WithMetricsCollector

func WithMetricsCollector(ctx context.Context, collector MetricsCollector) context.Context

WithMetricsCollector returns a derived context containing the provided collector.

func WritePrefix

func WritePrefix(ctx context.Context, w io.Writer, prefix HandlerPrefix) error

Types

type ConnInfo

type ConnInfo struct {
	// contains filtered or unexported fields
}

func MustConnInfo

func MustConnInfo(addr *net.UDPAddr, tlsInsecure bool) ConnInfo

func MustNewConnInfoFromFullString

func MustNewConnInfoFromFullString(s string) ConnInfo

func NewConnInfo

func NewConnInfo(addr *net.UDPAddr, tlsInsecure bool) (ConnInfo, error)

func NewConnInfoFromFullString

func NewConnInfoFromFullString(s string) (ConnInfo, error)

func NewConnInfoFromStringAddr

func NewConnInfoFromStringAddr(s string, tlsInsecure bool) (ci ConnInfo, _ error)

func UnsafeConnInfo

func UnsafeConnInfo(addr *net.UDPAddr, tlsInsecure bool) ConnInfo

func (ConnInfo) Addr

func (c ConnInfo) Addr() net.Addr

func (ConnInfo) IsValid

func (c ConnInfo) IsValid([]byte) error

func (ConnInfo) MarshalText

func (c ConnInfo) MarshalText() ([]byte, error)

func (ConnInfo) String

func (c ConnInfo) String() string

func (ConnInfo) TLSInsecure

func (c ConnInfo) TLSInsecure() bool

func (ConnInfo) UDPAddr

func (c ConnInfo) UDPAddr() *net.UDPAddr

func (*ConnInfo) UnmarshalText

func (c *ConnInfo) UnmarshalText(b []byte) error

type ConnInfoDialFunc

type ConnInfoDialFunc func(context.Context, ConnInfo) (Streamer, error)

func NewConnInfoDialFunc

func NewConnInfoDialFunc(
	quicconfigf func() *quic.Config,
	tlsconfigf func() *tls.Config,
) ConnInfoDialFunc

type Connection

type Connection struct {
	// contains filtered or unexported fields
}

func Dial

func Dial(
	ctx context.Context,
	addr *net.UDPAddr,
	tlsConfig *tls.Config,
	quicConfig *quic.Config,
) (*Connection, error)

func (*Connection) Close

func (c *Connection) Close() error

func (*Connection) Context

func (c *Connection) Context() context.Context

func (*Connection) ID

func (c *Connection) ID() string

func (*Connection) OpenStream

func (c *Connection) OpenStream(ctx context.Context) (io.Reader, io.WriteCloser, func() error, error)

func (*Connection) Stream

func (c *Connection) Stream(ctx context.Context, f StreamFunc) error

type ConnectionPool

type ConnectionPool struct {
	Stop func()
	// contains filtered or unexported fields
}

func NewConnectionPool

func NewConnectionPool(
	size uint64,
	dialf ConnInfoDialFunc,
) (*ConnectionPool, error)

func (*ConnectionPool) Close

func (c *ConnectionPool) Close(ci ConnInfo) bool

func (*ConnectionPool) CloseAll

func (c *ConnectionPool) CloseAll() error

func (*ConnectionPool) Dial

func (c *ConnectionPool) Dial(ctx context.Context, ci ConnInfo) (Streamer, error)

type Handler

func TimeoutHandler

func TimeoutHandler(handler Handler, f func() time.Duration) Handler

type HandlerName

type HandlerName string

func (HandlerName) Prefix

func (h HandlerName) Prefix() HandlerPrefix

func (HandlerName) String

func (h HandlerName) String() string

type HandlerPrefix

type HandlerPrefix [32]byte
var ZeroPrefix HandlerPrefix

func HashPrefix

func HashPrefix(s HandlerName) HandlerPrefix

func (HandlerPrefix) String

func (p HandlerPrefix) String() string

type MetricsCollector

type MetricsCollector interface {
	RecordQuicBytesSent(uint64)
	RecordQuicBytesReceived(uint64)
	RecordQuicStreamOpened()
	RecordQuicStreamClosed()
	RecordQuicConnectionOpened()
	RecordQuicConnectionClosed()
	RecordMemberlistBroadcast()
	RecordMemberlistMessageReceived()
	SetMemberlistMembers(int)
}

MetricsCollector represents the subset of metrics hooks used by the network stack. Implementations are expected to be concurrency-safe.

func GetMetricsCollector

func GetMetricsCollector(ctx context.Context) MetricsCollector

GetMetricsCollector extracts the MetricsCollector stored in the context, if any.

type OpenStreamFunc

type OpenStreamFunc func(context.Context) (io.Reader, io.WriteCloser, func() error, error)

type PrefixHandler

type PrefixHandler struct {
	*logging.Logging
	// contains filtered or unexported fields
}

func NewPrefixHandler

func NewPrefixHandler(errorHandler ErrorHandler) *PrefixHandler

func (*PrefixHandler) Add

func (h *PrefixHandler) Add(name HandlerName, handler Handler) *PrefixHandler

func (*PrefixHandler) Handler

func (h *PrefixHandler) Handler(
	ctx context.Context, addr net.Addr, r io.Reader, w io.WriteCloser,
) (context.Context, error)

func (*PrefixHandler) SetHandlerFunc

func (h *PrefixHandler) SetHandlerFunc(f func(Handler) Handler)

type Server

type Server struct {
	*logging.Logging
	*util.ContextDaemon
	// contains filtered or unexported fields
}

func NewServer

func NewServer(
	bind *net.UDPAddr,
	tlsconfig *tls.Config,
	quicconfig *quic.Config,
	handler Handler,
	maxStreamTimeout func() time.Duration,
) (*Server, error)

type StreamFunc

type StreamFunc func(context.Context, io.Reader, io.WriteCloser) error

type Streamer

type Streamer interface {
	Stream(context.Context, StreamFunc) error
	OpenStream(context.Context) (io.Reader, io.WriteCloser, func() error, error)
	Close() error
	Context() context.Context
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL