Documentation

Index

Constants

View Source
const (

	// DefaultResponseTimeout is the default timeout for responses after a
	// request is successfully sent.
	DefaultResponseTimeout = 30 * time.Second
)

Variables

View Source
var ErrCertRequired = fmt.Errorf("certificate required")

    ErrCertRequired is the error returned when a ws connection fails because no cert was provided.

    View Source
    var ErrInvalidCert = fmt.Errorf("invalid certificate")

      ErrInvalidCert is the error returned when attempting to use an invalid cert to set up a ws connection.

      Functions

      This section is empty.

      Types

      type WsCfg

      type WsCfg struct {
      	// URL is the websocket endpoint URL.
      	URL string
      
      	// The maximum time in seconds to wait for a ping from the server. This
      	// should be larger than the server's ping interval to allow for network
      	// latency.
      	PingWait time.Duration
      
      	// The server's certificate.
      	Cert []byte
      
      	// ReconnectSync runs the needed reconnection synchronization after
      	// a reconnect.
      	ReconnectSync func()
      
      	// ConnectEventFunc runs whenever connection status changes.
      	//
      	// NOTE: Disconnect event notifications may lag behind actual
      	// disconnections.
      	ConnectEventFunc func(bool)
      
      	// Logger is the logger for the WsConn.
      	Logger dex.Logger
      
      	// NetDialContext specifies an optional dialer context to use.
      	NetDialContext func(context.Context, string, string) (net.Conn, error)
      }

        WsCfg is the configuration struct for initializing a WsConn.

        type WsConn

        type WsConn interface {
        	NextID() uint64
        	IsDown() bool
        	Send(msg *msgjson.Message) error
        	Request(msg *msgjson.Message, respHandler func(*msgjson.Message)) error
        	RequestWithTimeout(msg *msgjson.Message, respHandler func(*msgjson.Message), expireTime time.Duration, expire func()) error
        	Connect(ctx context.Context) (*sync.WaitGroup, error)
        	MessageSource() <-chan *msgjson.Message
        }

          WsConn is an interface for a websocket client.

          func NewWsConn

          func NewWsConn(cfg *WsCfg) (WsConn, error)

            NewWsConn creates a client websocket connection.

            Source Files