Documentation ¶
Index ¶
- Constants
- Variables
- type BlockFilter
- type Channel
- type Client
- func (c *Client) ApplyFilters(msg Subscribe) error
- func (c *Client) Close() error
- func (c *Client) DetachFilters(msg Unsubscribe) error
- func (c *Client) Filters() *Filters
- func (c *Client) Id() uint64
- func (c *Client) Notify(msg any)
- func (c *Client) ReadMessages(ctx context.Context, ws *websocket.Conn, log echo.Logger)
- func (c *Client) WriteMessages(ctx context.Context, ws *websocket.Conn, log echo.Logger)
- type ClientHandler
- type Filterable
- type Filters
- type GasPriceFilter
- type HeadFilter
- type INotification
- type Manager
- func (manager *Manager) AddClientToChannel(channel string, client *Client)
- func (manager *Manager) Close() error
- func (manager *Manager) GasTrackerHandler(_ context.Context, state gas.GasPrice) error
- func (manager *Manager) Handle(c echo.Context) error
- func (manager *Manager) RemoveClientFromChannel(channel string, client *Client)
- func (manager *Manager) Start(ctx context.Context)
- type Message
- type Notification
- type Subscribe
- type TransactionFilters
- type Unsubscribe
Constants ¶
View Source
const ( MethodSubscribe = "subscribe" MethodUnsubscribe = "unsubscribe" )
methods
View Source
const ( ChannelHead = "head" ChannelBlocks = "blocks" ChannelGasPrice = "gas_price" )
channels
Variables ¶
View Source
var ( ErrUnknownMethod = errors.New("unknown method") ErrUnknownChannel = errors.New("unknown channel") )
Functions ¶
This section is empty.
Types ¶
type BlockFilter ¶ added in v1.4.0
type BlockFilter struct{}
func (BlockFilter) Filter ¶ added in v1.4.0
func (f BlockFilter) Filter(c client, msg Notification[*responses.Block]) bool
type Channel ¶
type Channel[I any, M INotification] struct { // contains filtered or unexported fields }
func NewChannel ¶
func NewChannel[I any, M INotification](processor processor[I, M], filters Filterable[M]) *Channel[I, M]
func (*Channel[I, M]) RemoveClient ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) ApplyFilters ¶
func (*Client) DetachFilters ¶
func (c *Client) DetachFilters(msg Unsubscribe) error
func (*Client) ReadMessages ¶
type ClientHandler ¶ added in v1.9.9
type Filterable ¶
type Filterable[M INotification] interface { Filter(c client, msg Notification[M]) bool }
type GasPriceFilter ¶ added in v1.9.10
type GasPriceFilter struct{}
func (GasPriceFilter) Filter ¶ added in v1.9.10
func (f GasPriceFilter) Filter(c client, msg Notification[*responses.GasPrice]) bool
type HeadFilter ¶
type HeadFilter struct{}
func (HeadFilter) Filter ¶
func (f HeadFilter) Filter(c client, msg Notification[*responses.State]) bool
type INotification ¶ added in v1.4.0
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func (*Manager) AddClientToChannel ¶
func (*Manager) GasTrackerHandler ¶ added in v1.9.10
func (*Manager) Handle ¶
Handle godoc
@Summary Websocket API @Description.markdown websocket @Tags websocket @ID websocket @x-internal true @Produce json @Router /ws [get]
func (*Manager) RemoveClientFromChannel ¶
type Message ¶
type Message struct { Method string `json:"method" validate:"required,oneof=subscribe,unsubscribe"` Body json.RawMessage `json:"body" validate:"required"` }
type Notification ¶ added in v1.4.0
type Notification[T INotification] struct { Channel string `json:"channel"` Body T `json:"body"` }
func NewBlockNotification ¶ added in v1.4.0
func NewBlockNotification(block responses.Block) Notification[*responses.Block]
func NewGasPriceNotification ¶ added in v1.9.10
func NewGasPriceNotification(value responses.GasPrice) Notification[*responses.GasPrice]
func NewStateNotification ¶ added in v1.4.0
func NewStateNotification(state responses.State) Notification[*responses.State]
type Subscribe ¶
type Subscribe struct { Channel string `json:"channel" validate:"required,oneof=head tx"` Filters json.RawMessage `json:"filters" validate:"required"` }
type TransactionFilters ¶
type Unsubscribe ¶
type Unsubscribe struct {
Channel string `json:"channel" validate:"required,oneof=head tx"`
}
Click to show internal directories.
Click to hide internal directories.