Documentation
¶
Index ¶
- Constants
- Variables
- type Connection
- type Dialer
- type Egress
- type Http3ClientConfig
- type Option
- func AddConnectListener(listener event.ConnectListener, cancel ...*event.CancelFunc) Option
- func AddDisconnectListener(listener event.DisconnectListener, cancel ...*event.CancelFunc) Option
- func AddHeartbeatListener(listener event.HeartbeatListener, cancel ...*event.CancelFunc) Option
- func AddMessageListener(listener event.MsgListener, cancel ...*event.CancelFunc) Option
- func AdditionalHeaders(headers http.Header) Option
- func ConveyDecorator(f func(http.Header) error) Option
- func CredentialsDecorator(f func(http.Header) error) Option
- func DeviceID(id wrp.DeviceID) Option
- func Enabled(enabled bool) Option
- func FetchURL(f func(context.Context) (string, error)) Option
- func FetchURLTimeout(d time.Duration) Option
- func HTTP3Client(c *Http3ClientConfig) Option
- func KeepAliveInterval(d time.Duration) Option
- func NowFunc(f func() time.Time) Option
- func Once(once ...bool) Option
- func RetryPolicy(pf retry.PolicyFactory) Option
- func SendTimeout(d time.Duration) Option
- func URL(url string) Option
- type QuicClient
- func (qc *QuicClient) AddMessageListener(listener event.MsgListener) event.CancelFunc
- func (qc *QuicClient) HandleWrp(m wrp.Message) error
- func (qc *QuicClient) IsEnabled() bool
- func (qc *QuicClient) Name() string
- func (qc *QuicClient) Send(ctx context.Context, msg wrp.Message) error
- func (qc *QuicClient) Start()
- func (qc *QuicClient) Stop()
- type QuicDialer
- type Redirector
- type UrlRedirector
Constants ¶
const (
Name = "quic"
)
Variables ¶
var ( ErrMisconfiguredQuic = errors.New("misconfigured Quic") ErrClosed = errors.New("quic connection closed") ErrInvalidMsgType = errors.New("invalid message type") ErrFromRedirectServer = errors.New("non-300 response from redirect server") ErrSendTimeout = errors.New("wrp message send timed out") )
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection interface {
// AcceptStream returns the next stream opened by the peer, blocking until one is available.
// If the connection was closed due to a timeout, the error satisfies
// the net.Error interface, and Timeout() will be true.
AcceptStream(context.Context) (quic.Stream, error)
// AcceptUniStream returns the next unidirectional stream opened by the peer, blocking until one is available.
// If the connection was closed due to a timeout, the error satisfies
// the net.Error interface, and Timeout() will be true.
AcceptUniStream(context.Context) (quic.ReceiveStream, error)
// OpenStream opens a new bidirectional QUIC stream.
// There is no signaling to the peer about new streams:
// The peer can only accept the stream after data has been sent on the stream,
// or the stream has been reset or closed.
// When reaching the peer's stream limit, it is not possible to open a new stream until the
// peer raises the stream limit. In that case, a StreamLimitReachedError is returned.
OpenStream() (quic.Stream, error)
// OpenStreamSync opens a new bidirectional QUIC stream.
// It blocks until a new stream can be opened.
// There is no signaling to the peer about new streams:
// The peer can only accept the stream after data has been sent on the stream,
// or the stream has been reset or closed.
OpenStreamSync(context.Context) (quic.Stream, error)
// OpenUniStream opens a new outgoing unidirectional QUIC stream.
// There is no signaling to the peer about new streams:
// The peer can only accept the stream after data has been sent on the stream,
// or the stream has been reset or closed.
// When reaching the peer's stream limit, it is not possible to open a new stream until the
// peer raises the stream limit. In that case, a StreamLimitReachedError is returned.
OpenUniStream() (quic.SendStream, error)
// OpenUniStreamSync opens a new outgoing unidirectional QUIC stream.
// It blocks until a new stream can be opened.
// There is no signaling to the peer about new streams:
// The peer can only accept the stream after data has been sent on the stream,
// or the stream has been reset or closed.
OpenUniStreamSync(context.Context) (quic.SendStream, error)
// LocalAddr returns the local address.
LocalAddr() net.Addr
// RemoteAddr returns the address of the peer.
RemoteAddr() net.Addr
// CloseWithError closes the connection with an error.
// The error string will be sent to the peer.
CloseWithError(quic.ApplicationErrorCode, string) error
// Context returns a context that is cancelled when the connection is closed.
// The cancellation cause is set to the error that caused the connection to
// close, or `context.Canceled` in case the listener is closed first.
Context() context.Context
// ConnectionState returns basic details about the QUIC connection.
// Warning: This API should not be considered stable and might change soon.
ConnectionState() quic.ConnectionState
// SendDatagram sends a message using a QUIC datagram, as specified in RFC 9221.
// There is no delivery guarantee for DATAGRAM frames, they are not retransmitted if lost.
// The payload of the datagram needs to fit into a single QUIC packet.
// In addition, a datagram may be dropped before being sent out if the available packet size suddenly decreases.
// If the payload is too large to be sent at the current time, a DatagramTooLargeError is returned.
SendDatagram(payload []byte) error
// ReceiveDatagram gets a message received in a datagram, as specified in RFC 9221.
ReceiveDatagram(context.Context) ([]byte, error)
}
type Egress ¶
type Egress interface {
// HandleWrp is called whenever a message targets something other than this device.
HandleWrp(m wrp.Message) error
}
Egress interface is the egress route used to handle wrp messages that targets something other than this device
type Http3ClientConfig ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is a functional option type for WS.
func AddConnectListener ¶
func AddConnectListener(listener event.ConnectListener, cancel ...*event.CancelFunc) Option
AddConnectListener adds a connect listener to the WS connection.
func AddDisconnectListener ¶
func AddDisconnectListener(listener event.DisconnectListener, cancel ...*event.CancelFunc) Option
AddDisconnectListener adds a disconnect listener to the WS connection.
func AddHeartbeatListener ¶
func AddHeartbeatListener(listener event.HeartbeatListener, cancel ...*event.CancelFunc) Option
AddHeartbeatListener adds a heartbeat listener to the WS connection.
func AddMessageListener ¶
func AddMessageListener(listener event.MsgListener, cancel ...*event.CancelFunc) Option
AddMessageListener adds a message listener to the WS connection. The listener will be called for every message received from the WS.
func AdditionalHeaders ¶
AdditionalHeaders sets the additional headers for the WS connection.
func CredentialsDecorator ¶
CredentialsDecorator provides the credentials decorator for the WS connection.
func FetchURLTimeout ¶
FetchURLTimeout sets the FetchURLTimeout for the WS connection. If this is not set, the default is 30 seconds.
func HTTP3Client ¶
func HTTP3Client(c *Http3ClientConfig) Option
HTTPClient is the configuration for the HTTP3 client used for connection attempts.
func KeepAliveInterval ¶
KeepAliveInterval sets the keep alive interval for the WS connection. If this is not set, the default is 30 seconds.
func RetryPolicy ¶
func RetryPolicy(pf retry.PolicyFactory) Option
RetryPolicy sets the retry policy factory used for delaying between retry attempts for reconnection.
func SendTimeout ¶
SendTimeout sets the send timeout for the WS connection.
type QuicClient ¶
type QuicClient struct {
// contains filtered or unexported fields
}
func New ¶
func New(opts ...Option) (*QuicClient, error)
New creates a new http3 connection with the given options.
func (*QuicClient) AddMessageListener ¶
func (qc *QuicClient) AddMessageListener(listener event.MsgListener) event.CancelFunc
AddMessageListener adds a message listener to the quic connection. The listener will be called for every message received from the cloud.
func (*QuicClient) IsEnabled ¶
func (qc *QuicClient) IsEnabled() bool
func (*QuicClient) Name ¶
func (qc *QuicClient) Name() string
func (*QuicClient) Start ¶
func (qc *QuicClient) Start()
Start starts the http3 connection and a long running goroutine to maintain the connection.
type QuicDialer ¶
type QuicDialer struct {
// contains filtered or unexported fields
}
func (*QuicDialer) DialQuic ¶
func (qd *QuicDialer) DialQuic(ctx context.Context, url *url.URL) (quic.Connection, error)
NOTE - when using an http.Client, the quic connection seems to always get re-created and the client no longer had access to the current quic connection. The below "dialer" uses the http3.ClientConn api directly and that api uses the passed in connection.
type Redirector ¶
type UrlRedirector ¶
type UrlRedirector struct {
// contains filtered or unexported fields
}