Documentation
¶
Index ¶
- Constants
- Variables
- type Connection
- type ConnectionWrapper
- 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 AddMessageListener(listener event.MsgListener, cancel ...*event.CancelFunc) Option
- func AdditionalHeaders(headers http.Header) Option
- func ConveyDecorator(f func(http.Header) error) Option
- func ConveyMsgDecorator(f func(*wrp.Message) 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) AddConnectListener(listener event.ConnectListener) event.CancelFunc
- 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 Stream
- 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") ErrHttp3NotSupported = errors.New("http3 protocol not supported") )
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) (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) (Stream, 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() (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) (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() (Stream, 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) (Stream, 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
}
type ConnectionWrapper ¶ added in v0.8.0
type ConnectionWrapper struct {
// contains filtered or unexported fields
}
func (ConnectionWrapper) AcceptStream ¶ added in v0.8.0
func (w ConnectionWrapper) AcceptStream(ctx context.Context) (Stream, error)
func (ConnectionWrapper) CloseWithError ¶ added in v0.8.0
func (w ConnectionWrapper) CloseWithError(code quic.ApplicationErrorCode, msg string) error
func (ConnectionWrapper) OpenStream ¶ added in v0.8.0
func (w ConnectionWrapper) OpenStream() (Stream, 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 Quic.
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 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 ConveyDecorator ¶
writes identity metadata to convey header on connect with the cloud
func ConveyMsgDecorator ¶ added in v0.8.2
writes identity metadata directly to every outbound message.
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) AddConnectListener ¶ added in v0.7.35
func (qc *QuicClient) AddConnectListener(listener event.ConnectListener) event.CancelFunc
AddConnectListener adds a connect listener to the quic connection. The listener will be called every time the connection succeeds or fails
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) (Connection, error)
NOTE - with an older version of quic: 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. However, retry now that quic has been updated.
type Redirector ¶
type UrlRedirector ¶
type UrlRedirector struct {
// contains filtered or unexported fields
}