Skip to content

Import path: gitlab.soludian.com/soludian/fountain/libs/fnet/fquic

fquic

go
import "gitlab.soludian.com/soludian/fountain/libs/fnet/fquic"

Index

Constants

go
const (
    KPackageName = "fquic"
)

Variables

go
var KDefaultServerName = env.GetFullAppService(KPackageName)

func New

go
func New() runnable.AppInstance

New creates a new QUIC server instance with default configuration

func SendMessageToStream

go
func SendMessageToStream(stream *quic.Stream, server *Server, cntl *codec.MessageController, msg proto.Message) error

SendMessageToStream sends a protobuf message to an existing stream

func WithConfig

go
func WithConfig(c *config) runnable.AppInstance

WithConfig creates a new QUIC server instance with provided configuration

func WithConfigKey

go
func WithConfigKey(configKey string) runnable.AppInstance

WithConfigKey creates a new QUIC server instance with configuration from config key

type DefaultQUICCodec

DefaultQUICCodec implements QUICCodec for QUIC streams Similar to DefaultTCPCodec but adapted for QUIC

go
type DefaultQUICCodec struct{}

func (*DefaultQUICCodec) Close

go
func (c *DefaultQUICCodec) Close() error

Close closes the codec (no-op for stateless codec)

func (*DefaultQUICCodec) Receive

go
func (c *DefaultQUICCodec) Receive(stream *quic.Stream) (*codec.Message, error)

Receive reads a codec.Message from QUIC stream Uses the same protocol format as TCP codec

func (*DefaultQUICCodec) Send

go
func (c *DefaultQUICCodec) Send(stream *quic.Stream, msg *codec.Message) error

Send sends a codec.Message over QUIC stream Uses the same protocol format as TCP codec

type Handle

Handle defines the function signature for message handlers Similar to ftcp pattern: func(*connect.Connection, *codec.MessageController, proto.Message) error

go
type Handle func(*connect.Connection, *codec.MessageController, proto.Message) error

func FindHandler

go
func FindHandler(msg proto.Message, server *Server) Handle

FindHandler finds a handler for a protobuf message

type Option

Option defines the interface for configuring QUIC server options

go
type Option interface {
    Apply(c *config)
}

func WithAddr

go
func WithAddr(addr string) Option

WithAddr sets the server address

func WithConnectionReceiveWindow

go
func WithConnectionReceiveWindow(initial, max uint64) Option

WithConnectionReceiveWindow sets the initial and maximum connection receive window

func WithDatagrams

go
func WithDatagrams(enable bool) Option

WithDatagrams enables or disables datagram support

func WithHandshakeIdleTimeout

go
func WithHandshakeIdleTimeout(timeout time.Duration) Option

WithHandshakeIdleTimeout sets the handshake idle timeout

func WithKeepAlivePeriod

go
func WithKeepAlivePeriod(period time.Duration) Option

WithKeepAlivePeriod sets the keep-alive period

func WithMaxIdleTimeout

go
func WithMaxIdleTimeout(timeout time.Duration) Option

WithMaxIdleTimeout sets the maximum idle timeout

func WithMaxIncomingStreams

go
func WithMaxIncomingStreams(max int64) Option

WithMaxIncomingStreams sets the maximum number of incoming bidirectional streams

func WithMaxIncomingUniStreams

go
func WithMaxIncomingUniStreams(max int64) Option

WithMaxIncomingUniStreams sets the maximum number of incoming unidirectional streams

func WithMaxTokenAge

go
func WithMaxTokenAge(age time.Duration) Option

WithMaxTokenAge sets the maximum token age

func WithMetrics

go
func WithMetrics(enable bool) Option

WithMetrics enables or disables metrics

func WithName

go
func WithName(name string) Option

WithName sets the server name

func WithSlowLogThreshold

go
func WithSlowLogThreshold(threshold time.Duration) Option

WithSlowLogThreshold sets the slow log threshold

func WithStreamReceiveWindow

go
func WithStreamReceiveWindow(initial, max uint64) Option

WithStreamReceiveWindow sets the initial and maximum stream receive window

func WithTLS

go
func WithTLS(certFile, keyFile string) Option

WithTLS sets the TLS certificate and key files

type OptionFunc

OptionFunc is a function that implements the Option interface

go
type OptionFunc func(c *config)

func (OptionFunc) Apply

go
func (f OptionFunc) Apply(c *config)

Apply implements the Option interface

type QUICCodec

QUICCodec interface for QUIC message encoding/decoding

go
type QUICCodec interface {
    Send(stream *quic.Stream, msg *codec.Message) error
    Receive(stream *quic.Stream) (*codec.Message, error)
    Close() error
}

func NewQUICCodec

go
func NewQUICCodec() QUICCodec

NewQUICCodec creates a new QUIC codec

type Server

Server represents a QUIC server instance

go
type Server struct {
    *runnable.ServerInstance
    // contains filtered or unexported fields
}

func GetFountainInstance

go
func GetFountainInstance(opts ...Option) *Server

GetFountainInstance is an alias for InstallFountainInstance for compatibility

func InstallFountainInstance

go
func InstallFountainInstance(opts ...Option) *Server

InstallFountainInstance creates and configures a QUIC server instance

func (*Server) BroadcastMessage

go
func (s *Server) BroadcastMessage(msg proto.Message) error

BroadcastMessage broadcasts a message to all connected clients using server-level encoding

func (*Server) BroadcastRawData

go
func (s *Server) BroadcastRawData(data []byte) error

BroadcastRawData broadcasts raw bytes to all connected clients using worker pool

func (*Server) Counter

go
func (s *Server) Counter() metrics.Counter

Counter returns the metrics counter

func (*Server) Destroy

go
func (s *Server) Destroy() error

Destroy gracefully shuts down the server

func (*Server) FindServiceHandler

go
func (s *Server) FindServiceHandler(msg proto.Message) Handle

FindServiceHandler finds a protobuf message handler

func (*Server) FindStreamHandler

go
func (s *Server) FindStreamHandler(name string) StreamHandler

FindStreamHandler finds a stream handler by name

func (*Server) GetConnectionManager

go
func (s *Server) GetConnectionManager() *connect.ConnectionManager

GetConnectionManager returns the connection manager for advanced operations

func (*Server) GetLocalAddr

go
func (s *Server) GetLocalAddr() net.Addr

GetLocalAddr returns the local address the server is listening on

func (*Server) GetMessageCodec

go
func (s *Server) GetMessageCodec() *codec.MessageController

GetMessageCodec returns the server-level message codec

func (*Server) Histogram

go
func (s *Server) Histogram() metrics.Histogram

Histogram returns the metrics histogram

func (*Server) Initialize

go
func (s *Server) Initialize() error

Initialize prepares the server for serving

func (*Server) PackageName

go
func (s *Server) PackageName() string

PackageName package name

func (*Server) RegisterServiceHandler

go
func (s *Server) RegisterServiceHandler(x proto.Message, handler Handle)

RegisterServiceHandler registers a protobuf message handler Similar to ftcp RegisterServiceHandler

func (*Server) RegisterStreamHandler

go
func (s *Server) RegisterStreamHandler(name string, handler StreamHandler)

RegisterStreamHandler registers a stream handler by name

func (*Server) SendMessageByConn

go
func (s *Server) SendMessageByConn(conn *quic.Conn, cntl *codec.MessageController, msg proto.Message) error

SendMessageByConn sends a protobuf message over QUIC connection. It wraps a raw *quic.Conn in a transient connect.Connection so the shared SendMessage codec path can be reused. Callers that already have a managed connect.Connection should call connect.Connection.SendMessage directly to avoid the wrapping cost.

func (*Server) SendMessageByConnID

go
func (s *Server) SendMessageByConnID(key string, msg *codec.Message) error

SendMessageByConnID func; Send data according to addr

func (*Server) Serving

go
func (s *Server) Serving()

Serving starts serving QUIC connections

func (*Server) SetCallback

go
func (s *Server) SetCallback(callback ServerCallback)

SetCallback sets the server callback for connection events

func (*Server) Use

go
func (s *Server) Use(mw middleware.Middleware)

Use adds a middleware to the server

type ServerCallback

ServerCallback defines the callback interface for QUIC server events

go
type ServerCallback interface {
    OnNewQUICConnection(conn *quic.Conn)
    OnQUICConnectionClosed(conn *quic.Conn)
    OnQUICStream(stream *quic.Stream)
}

type StreamHandler

StreamHandler defines handler function for QUIC streams

go
type StreamHandler func(stream *quic.Stream) error

Generated by gomarkdoc