subscription

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnknownState       State = iota // UnknownState subscription state is not registered, but doesn't imply Inactive
	SubscribingState                // SubscribingState means channel is in the process of subscribing
	SubscribedState                 // SubscribedState means the channel has finished a successful and acknowledged subscription
	UnsubscribingState              // UnsubscribingState means the channel has started to unsubscribe, but not yet confirmed

	TickerChannel    = "ticker"    // TickerChannel Subscription Type
	OrderbookChannel = "orderbook" // OrderbookChannel Subscription Type
	CandlesChannel   = "candles"   // CandlesChannel Subscription Type
	AllOrdersChannel = "allOrders" // AllOrdersChannel Subscription Type
	AllTradesChannel = "allTrades" // AllTradesChannel Subscription Type
	MyTradesChannel  = "myTrades"  // MyTradesChannel Subscription Type
	MyOrdersChannel  = "myOrders"  // MyOrdersChannel Subscription Type
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultKey

type DefaultKey struct {
	Channel string
	Pair    currency.Pair
	Asset   asset.Item
}

DefaultKey is the fallback key for AddSuccessfulSubscriptions

type State

type State uint8

State tracks the status of a subscription channel

type Subscription

type Subscription struct {
	Enabled       bool                   `json:"enabled"`
	Key           any                    `json:"-"`
	Channel       string                 `json:"channel,omitempty"`
	Pair          currency.Pair          `json:"pair,omitempty"`
	Asset         asset.Item             `json:"asset,omitempty"`
	Params        map[string]interface{} `json:"params,omitempty"`
	State         State                  `json:"-"`
	Interval      kline.Interval         `json:"interval,omitempty"`
	Levels        int                    `json:"levels,omitempty"`
	Authenticated bool                   `json:"authenticated,omitempty"`
}

Subscription container for streaming subscriptions

func (*Subscription) EnsureKeyed

func (s *Subscription) EnsureKeyed() any

EnsureKeyed sets the default key on a channel if it doesn't have one Returns key for convenience

func (*Subscription) MarshalJSON

func (s *Subscription) MarshalJSON() ([]byte, error)

MarshalJSON generates a JSON representation of a Subscription, specifically for config writing The only reason it exists is to avoid having to make Pair a pointer, since that would be generally painful If Pair becomes a pointer, this method is redundant and should be removed

func (*Subscription) String

func (s *Subscription) String() string

String implements the Stringer interface for Subscription, giving a human representation of the subscription

Jump to

Keyboard shortcuts

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