websocket

package
v0.0.0-...-f501dc8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

type Channel struct {
	Name       string   `json:"name"`
	ProductIds []string `json:"product_ids"`
}

type Connector

type Connector interface {
	ReadJSON(interface{}) error
	WriteJSON(interface{}) error
}

func DefaultConnector

func DefaultConnector(url string) (Connector, error)

DefaultWebsocketConnector returns a new websocket as the default connection.

func New

func New(url string) (Connector, error)

NewWebsocket will return a new coinbase websocket connection

func NewMock

func NewMock() (Connector, error)

type Creator

type Creator func(string) (Connector, error)

type Message

type Message struct {
	Type     string    `json:"type"`
	Products []string  `json:"product_ids"`
	Channels []Channel `json:"channels"`
}

func NewProductsMessage

func NewProductsMessage(products []string, channels []Channel) (*Message, error)

NewWebsocket will return a new websocket subscription that can be used to get a feed of real-time market data.

func (*Message) Subscribe

func (msg *Message) Subscribe(conn Connector) error

Subscribe will use the websocket message to subscribe to a websocket connections, returning that connection or any errors that occured attempting to make it.

func (*Message) Unsubscribe

func (msg *Message) Unsubscribe(conn Connector) error

Unsubscribe will use the websocket message to unsubscribe to a connection.

type Mock

type Mock struct{}

func (*Mock) ReadJSON

func (conn *Mock) ReadJSON(_ interface{}) error

func (*Mock) WriteJSON

func (conn *Mock) WriteJSON(_ interface{}) error

type Websocket

type Websocket struct {
	*websocket.Conn
	Response *http.Response
}

Websocket holds the connection and response data for a coinbase websocket.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL