Documentation ¶
Index ¶
- Variables
- type AccountResult
- type Client
- func (c *Client) AccountSubscribe(account solana.PublicKey, commitment rpc.CommitmentType) (*Subscription, error)
- func (c *Client) Close()
- func (c *Client) CloseAndReconnect()
- func (c *Client) Dial(ctx context.Context) (err error)
- func (c *Client) IsConnected() bool
- func (c *Client) LogSubscribe(account solana.PublicKey, commitment rpc.CommitmentType) (*Subscription, error)
- func (c *Client) ProgramSubscribe(programId solana.PublicKey, commitment rpc.CommitmentType) (*Subscription, error)
- func (c *Client) SignatureSubscribe(signature string, commitment rpc.CommitmentType) (*Subscription, error)
- func (c *Client) SlotSubscribe() (*Subscription, error)
- type LogResult
- type ProgramResult
- type SignatureResult
- type SlotResult
- type Subscription
- type Websocket
- func (ws *Websocket) Close()
- func (ws *Websocket) Connect()
- func (ws *Websocket) Dial(urlStr string) error
- func (ws *Websocket) GetDialError() error
- func (ws *Websocket) GetHTTPResponse() *http.Response
- func (ws *Websocket) IsConnected() bool
- func (ws *Websocket) ReadMessage() (messageType int, message []byte, err error)
- func (ws *Websocket) WriteJSON(v interface{}) error
- func (ws *Websocket) WriteMessage(messageType int, data []byte) error
- type WsOpts
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotConnected = errors.New("websocket not connected") ErrUrlEmpty = errors.New("url can not be empty") ErrUrlWrongScheme = errors.New("websocket uri must start with ws or wss scheme") ErrUrlNamePassNotAllowed = errors.New("user name and password are not allowed in websocket uri") )
Functions ¶
This section is empty.
Types ¶
type AccountResult ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) AccountSubscribe ¶
func (c *Client) AccountSubscribe(account solana.PublicKey, commitment rpc.CommitmentType) (*Subscription, error)
func (*Client) CloseAndReconnect ¶
func (c *Client) CloseAndReconnect()
func (*Client) IsConnected ¶
func (*Client) LogSubscribe ¶
func (c *Client) LogSubscribe(account solana.PublicKey, commitment rpc.CommitmentType) (*Subscription, error)
func (*Client) ProgramSubscribe ¶
func (c *Client) ProgramSubscribe(programId solana.PublicKey, commitment rpc.CommitmentType) (*Subscription, error)
func (*Client) SignatureSubscribe ¶
func (c *Client) SignatureSubscribe(signature string, commitment rpc.CommitmentType) (*Subscription, error)
func (*Client) SlotSubscribe ¶
func (c *Client) SlotSubscribe() (*Subscription, error)
type ProgramResult ¶
type SignatureResult ¶
type SignatureResult struct { Context struct { Slot uint64 } `json:"context"` Value struct { Err interface{} `json:"err"` } `json:"value"` }
type SlotResult ¶
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
func (*Subscription) Recv ¶
func (s *Subscription) Recv(ctx context.Context) (interface{}, error)
Recv waits for a message to arrive through the WebSocket connection for this exact subscription.
It will either returns:
- `<value>, nil` If the stream has a message available
- `nil, err` If the subscription encounteted an error
- `nil, context.Canceled` If the context received was canceled
- `nil, context.DeadlineExceed` If the context timeout was reached
Upon receiving a `context.Canceled` or `context.DeadlineExceed`, the subscription is automatically unsubscribed.
*Future* It's not clear if `ctx context.Context` is appropriate here. Indeed, the gRPC way of doing things it to accept a `ctx context.Context` for the whole subscription lifecycle. The subscription is then tied to the context and closes automatically. The `Recv` method in this case does not accept a `ctx` object and uses the subscription one instead.
func (*Subscription) Unsubscribe ¶
func (s *Subscription) Unsubscribe()
type Websocket ¶
type Websocket struct { // Websocket ID Id uint64 // Websocket Meta Meta map[string]interface{} Logger *zap.Logger Errors chan<- error Reconnect bool // default to 2 seconds ReconnectIntervalMin time.Duration // default to 30 seconds ReconnectIntervalMax time.Duration // interval, default to 1.5 ReconnectIntervalFactor float64 // default to 2 seconds HandshakeTimeout time.Duration // Verbose suppress connecting/reconnecting messages. Verbose bool // Cal function OnConnect func(ws *Websocket) OnDisconnect func(ws *Websocket) OnConnectError func(ws *Websocket, err error) OnDisconnectError func(ws *Websocket, err error) OnReadError func(ws *Websocket, err error) OnWriteError func(ws *Websocket, err error) *websocket.Conn // contains filtered or unexported fields }
func (*Websocket) GetDialError ¶
func (*Websocket) GetHTTPResponse ¶
func (*Websocket) IsConnected ¶
func (*Websocket) ReadMessage ¶
Click to show internal directories.
Click to hide internal directories.