Documentation ¶
Index ¶
- Constants
- type AuthInfo
- type Client
- func (c *Client) Connect() error
- func (c *Client) Disconnect() error
- func (c *Client) Handshake() error
- func (c *Client) Reconnect() error
- func (c *Client) Send(e protocol.ChunkEncoder) error
- func (c *Client) SendCompressed(tag string, entries protocol.EntryList) error
- func (c *Client) SendCompressedFromBytes(tag string, entries []byte) error
- func (c *Client) SendForward(tag string, entries protocol.EntryList) error
- func (c *Client) SendMessage(tag string, record interface{}) error
- func (c *Client) SendMessageExt(tag string, record interface{}) error
- func (c *Client) SendPacked(tag string, entries protocol.EntryList) error
- func (c *Client) SendPackedFromBytes(tag string, entries []byte) error
- func (c *Client) SendRaw(m []byte) error
- func (c *Client) TransportPhase() bool
- type ConnFactory
- type ConnectionFactory
- type ConnectionOptions
- type DefaultWSConnectionFactory
- type HTTPError
- type IAMAuthInfo
- type MessageClient
- type Session
- type WSClient
- type WSConnectionFactory
- type WSConnectionOptions
- type WSSession
Constants ¶
const ( TextMessage = websocket.TextMessage BinaryMessage = websocket.BinaryMessage )
Expose message types as defined in underlying websocket library
const (
AuthorizationHeader = "Authorization"
)
const (
DefaultConnectionTimeout time.Duration = 60 * time.Second
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { ConnectionFactory RequireAck bool Timeout time.Duration AuthInfo AuthInfo Hostname string // contains filtered or unexported fields }
func New ¶
func New(opts ConnectionOptions) *Client
func (*Client) Connect ¶
Connect initializes the Session and Connection objects by opening a client connect to the target configured in the ConnectionFactory
func (*Client) Disconnect ¶
Disconnect terminates a client connection
func (*Client) Handshake ¶
Handshake initiates handshake mode. Users must call this before attempting to send any messages when the server is configured with a shared key, otherwise the server will reject any message events. Successful completion of the handshake puts the connection into message (or forward) mode, at which time the client is free to send event messages.
func (*Client) Send ¶
func (c *Client) Send(e protocol.ChunkEncoder) error
Send sends a single protocol.ChunkEncoder across the wire. If the session is not yet in transport phase, an error is returned, and no message is sent.
func (*Client) SendCompressed ¶
func (*Client) SendCompressedFromBytes ¶
func (*Client) SendForward ¶
func (*Client) SendMessage ¶
func (*Client) SendMessageExt ¶
func (*Client) SendPacked ¶
func (*Client) SendPackedFromBytes ¶
func (*Client) SendRaw ¶
SendRaw sends bytes across the wire. If the session is not yet in transport phase, an error is returned, and no message is sent.
func (*Client) TransportPhase ¶
TransportPhase indicates if the client has completed the initial connection handshake.
type ConnFactory ¶
type ConnFactory struct { // Network indicates the type of connection. The default value is "tcp". Network string Address string TLSConfig *tls.Config Timeout time.Duration }
ConnFactory is a light wrapper for net.Dial and tls.Dial. When TLSConfig is not nil, tls.Dial is called. Otherwise, net.Dial is used. See Go's net.Dial documentation for more information.
type ConnectionFactory ¶
ConnectionFactory implementations create new connections
type ConnectionOptions ¶
type ConnectionOptions struct { Factory ConnectionFactory RequireAck bool ConnectionTimeout time.Duration // TODO: // ReadTimeout time.Duration // WriteTimeout time.Duration AuthInfo AuthInfo }
type DefaultWSConnectionFactory ¶
type DefaultWSConnectionFactory struct { URL string AuthInfo *IAMAuthInfo TLSConfig *tls.Config }
DefaultWSConnectionFactory is used by the client if no other ConnectionFactory is provided.
func (*DefaultWSConnectionFactory) New ¶
func (wcf *DefaultWSConnectionFactory) New() (ext.Conn, error)
func (*DefaultWSConnectionFactory) NewSession ¶
func (wcf *DefaultWSConnectionFactory) NewSession(connection ws.Connection) *WSSession
type HTTPError ¶
func NewHTTPError ¶
type IAMAuthInfo ¶
type IAMAuthInfo struct {
// contains filtered or unexported fields
}
func NewIAMAuthInfo ¶
func NewIAMAuthInfo(token string) *IAMAuthInfo
func (*IAMAuthInfo) IAMToken ¶
func (ai *IAMAuthInfo) IAMToken() string
IAMToken returns the current token value. It is thread safe.
func (*IAMAuthInfo) SetIAMToken ¶
func (ai *IAMAuthInfo) SetIAMToken(token string)
SetIAMToken updates the token returned by IAMToken(). It is thread safe.
type MessageClient ¶
type MessageClient interface { Connect() error Disconnect() (err error) Reconnect() error Send(e protocol.ChunkEncoder) error SendCompressed(tag string, entries protocol.EntryList) error SendCompressedFromBytes(tag string, entries []byte) error SendForward(tag string, entries protocol.EntryList) error SendMessage(tag string, record interface{}) error SendMessageExt(tag string, record interface{}) error SendPacked(tag string, entries protocol.EntryList) error SendPackedFromBytes(tag string, entries []byte) error SendRaw(raw []byte) error }
MessageClient implementations send MessagePack messages to a peer
type WSClient ¶
type WSClient struct { ConnectionFactory WSConnectionFactory ConnectionOptions ws.ConnectionOptions // contains filtered or unexported fields }
WSClient manages the lifetime of a single websocket connection.
func NewWS ¶
func NewWS(opts WSConnectionOptions) *WSClient
func (*WSClient) Connect ¶
Connect initializes the Session and Connection objects by opening a websocket connection. If AuthInfo is not nil, the token it returns will be passed via the "Authentication" header during the initial HTTP call.
func (*WSClient) Disconnect ¶
Disconnect ends the current Session and terminates its websocket connection.
func (*WSClient) Send ¶
func (c *WSClient) Send(e protocol.ChunkEncoder) error
Send sends a single msgp.Encodable across the wire.
type WSConnectionFactory ¶
type WSConnectionOptions ¶
type WSConnectionOptions struct { ws.ConnectionOptions Factory WSConnectionFactory }
type WSSession ¶
type WSSession struct { URL string Connection ws.Connection }
WSSession represents a single websocket connection.
Directories ¶
Path | Synopsis |
---|---|
Code generated by counterfeiter.
|
Code generated by counterfeiter. |
ext/extfakes
Code generated by counterfeiter.
|
Code generated by counterfeiter. |
wsfakes
Code generated by counterfeiter.
|
Code generated by counterfeiter. |