Documentation ¶
Overview ¶
Package network provides functionality to work with the underlying QUIC protocol
Index ¶
Constants ¶
Variables ¶
var ( ErrorPanic = errors.New("panic") ErrorTimeout = errors.New("timeout") ErrorChannelClosed = errors.New("channel closed") )
var (
ErrorGenRes = errors.New("message does not need a response")
)
Functions ¶
func GenerateQuicConfig ¶
func GenerateQuicConfig(c Config) *quic.Config
Generate QUIC Config with defaults
Types ¶
type Channel ¶
type Channel struct {
// contains filtered or unexported fields
}
Channel
func NewChannel ¶
func NewChannel(log *logrus.Logger, stream quic.Stream, unmarshalers []ChannelUnmarshaler) *Channel
Create a new channel
func (*Channel) SendAndRead ¶
If the channel is not actively read, this function sends and reads a single message This method SHOULD NOT BE USED if the channel is actively being read. Just use the Send function.
type ChannelUnmarshaler ¶
type ChannelUnmarshaler func(mtype MessageType) (msg proto.Message, err error)
Unmarshals protobuf encoded data depending on the MessageType
type Config ¶
type Config interface { // Maximum number of concurrent streams open on connection MaxStreams() int16 // Use QUIC Datagram // This model does not guarantee a packet will be delivered UseDatagram() bool }
Config Interface
type Message ¶
type Message struct { // Message Context Ctx MessageContext // Message Options Opt MessageOptions // Message Body Body proto.Message }
Message
func NewMessage ¶
func NewMessage(mtype MessageType, mbody proto.Message) (msg *Message)
New Message with default options
func NewMessageWithAck ¶
func NewMessageWithAck(mtype MessageType, mbody proto.Message, timeout time.Duration) (msg *Message)
New Message which requires an ACK
func NewMessageWithOptions ¶
func NewMessageWithOptions(mtype MessageType, mbody proto.Message, nopt NewMessageOptions) (msg *Message)
New Message with custom options
type MessageContext ¶
type MessageContext struct { // Message ID Id string // Message needs an Acknowledgement Ack bool // Message is Acknowledgement Reply Ackr bool // Message Type Type MessageType }
Stores the context of a message
type MessageOptions ¶
type MessageOptions struct { // Duration after which the Message Request Timesout Timeout time.Duration }
Message Options
type NewMessageOptions ¶
type NewMessageOptions struct { // Message requires an ACK Ack bool // Message Timeout Duration Timeout time.Duration }
New Message Options
type PingResult ¶
type PingResult struct { // Ping Status Status bool // Ping Status Message Message string // Ping Address Addr string // Average time taken AvgTime time.Duration }
Stores the result of a ping request
type PingResults ¶
type PingResults struct { // Success Results Success []PingResult // Failed Results Failed []PingResult }
Stores results of PingAddrs
func PingAddrs ¶
func PingAddrs(addresses []string, asc bool) (result PingResults)
Ping a list of addresses and sort the results in asc or dsc order