ws2

package
v0.0.0-...-7fb57da Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultHandshakeTimeout = 45 * time.Second
View Source
var ErrReachedMaxConnectionsLimit = fmt.Errorf("reached max connections limit")
View Source
var ErrReachedMaxSubscriptionsLimit = fmt.Errorf("reached max subscriptions limit")
View Source
var ErrReachedMaxSubscriptionsPerClientLimit = fmt.Errorf("reached max subscriptions per client limit")

Functions

This section is empty.

Types

type AccountResult

type AccountResult struct {
	Context struct {
		Slot uint64
	} `json:"context"`
	Value struct {
		rpc.Account
	} `json:"value"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(rpcURL string, logger Logger, maxConnections int, maxSubscriptions int) *Client

func (*Client) AccountSubscribe

func (c *Client) AccountSubscribe(
	ctx context.Context,
	account string,
	commitment rpc.CommitmentType,
) error

AccountSubscribe subscribes to an account to receive notifications when the lamports or data for a given account public key changes.

func (*Client) AccountSubscribeWithOpts

func (c *Client) AccountSubscribeWithOpts(
	ctx context.Context,
	account string,
	commitment rpc.CommitmentType,
	encoding solana.EncodingType,
) error

AccountSubscribe subscribes to an account to receive notifications when the lamports or data for a given account public key changes.

func (*Client) Close

func (c *Client) Close()

func (*Client) Connect

func (c *Client) Connect(ctx context.Context) (err error)

Connect creates a new websocket client connecting to the provided endpoint.

func (*Client) ConnectWithOptions

func (c *Client) ConnectWithOptions(ctx context.Context, opt *Options) (err error)

ConnectWithOptions creates a new websocket client connecting to the provided endpoint with a http header if available The http header can be helpful to pass basic authentication params as prescribed ref https://github.com/gorilla/websocket/issues/209

func (*Client) GetSubscriptions

func (c *Client) GetSubscriptions() map[uint64]struct{}

func (*Client) Messages

func (c *Client) Messages() <-chan MessageWS

type Connection

type Connection struct {
	*websocket.Conn
	// contains filtered or unexported fields
}

func NewConnection

func NewConnection(conn *websocket.Conn, maxSubscriptions int, logger Logger) *Connection

func (*Connection) Close

func (c *Connection) Close()

func (*Connection) ID

func (c *Connection) ID() uint64

func (*Connection) Subscribe

func (c *Connection) Subscribe(
	params []interface{},
	conf map[string]interface{},
	subscriptionMethod string,
	unsubscribeMethod string,
	decoderFunc decoderFunc,
) (reqID uint64, err error)

type Logger

type Logger interface {
	Info(...interface{})
	Error(...interface{})
	Infof(string, ...interface{})
	Errorf(string, ...interface{})
}

type MessageError

type MessageError struct {
	// contains filtered or unexported fields
}

type MessageWS

type MessageWS struct {
	Account            string
	SubscriptionID     uint64
	Data               []byte
	ConnectionID       uint64
	SubscriptionMethod string
	Encoding           solana.EncodingType
}

type Options

type Options struct {
	HttpHeader       http.Header
	HandshakeTimeout time.Duration
}

type SubscriptionMeta

type SubscriptionMeta struct {
	Account            string
	UnsubscribeMethod  string
	SubscriptionMethod string
	Encoding           solana.EncodingType
}

Jump to

Keyboard shortcuts

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