Documentation ¶
Index ¶
- Constants
- Variables
- type ExactKey
- type IgnoringAssetKey
- type IgnoringPairsKey
- type List
- func (l List) Clone() List
- func (l List) Enabled() List
- func (l List) ExpandTemplates(e iExchange) (List, error)
- func (l List) GroupByPairs() []List
- func (l List) GroupPairs() (n List)
- func (l List) Private() List
- func (l List) Public() List
- func (l List) QualifiedChannels() []string
- func (l List) SetStates(state State) error
- func (l List) Strings() []string
- type MatchableKey
- type State
- type Store
- type Subscription
- func (s *Subscription) AddPairs(pairs ...currency.Pair)
- func (s *Subscription) Clone() *Subscription
- func (s *Subscription) EnsureKeyed() any
- func (s *Subscription) SetKey(key any)
- func (s *Subscription) SetPairs(pairs currency.Pairs)
- func (s *Subscription) SetState(state State) error
- func (s *Subscription) State() State
- func (s *Subscription) String() string
Constants ¶
const ( TickerChannel = "ticker" OrderbookChannel = "orderbook" CandlesChannel = "candles" AllOrdersChannel = "allOrders" AllTradesChannel = "allTrades" MyTradesChannel = "myTrades" MyOrdersChannel = "myOrders" MyWalletChannel = "myWallet" MyAccountChannel = "myAccount" HeartbeatChannel = "heartbeat" )
Channel constants
Variables ¶
var ( ErrNotFound = errors.New("subscription not found") ErrNotSinglePair = errors.New("only single pair subscriptions expected") ErrBatchingNotSupported = errors.New("subscription batching not supported") ErrInStateAlready = errors.New("subscription already in state") ErrInvalidState = errors.New("invalid subscription state") ErrDuplicate = errors.New("duplicate subscription") ErrUseConstChannelName = errors.New("must use standard channel name constants") ErrNotSupported = errors.New("subscription channel not supported") )
Public errors
Functions ¶
This section is empty.
Types ¶
type ExactKey ¶
type ExactKey struct {
*Subscription
}
ExactKey is key type for subscriptions where all the pairs in a Subscription must match exactly
func (ExactKey) GetSubscription ¶
func (k ExactKey) GetSubscription() *Subscription
GetSubscription returns the underlying subscription
func (ExactKey) Match ¶
func (k ExactKey) Match(eachKey MatchableKey) bool
Match implements MatchableKey Returns true if the key fields exactly matches the subscription, including all Pairs Does not check QualifiedChannel or Params
type IgnoringAssetKey ¶
type IgnoringAssetKey struct {
*Subscription
}
IgnoringAssetKey is a key type for finding subscriptions to group together for requests
func (IgnoringAssetKey) GetSubscription ¶
func (k IgnoringAssetKey) GetSubscription() *Subscription
GetSubscription returns the underlying subscription
func (IgnoringAssetKey) Match ¶
func (k IgnoringAssetKey) Match(eachKey MatchableKey) bool
Match implements MatchableKey
func (IgnoringAssetKey) String ¶
func (k IgnoringAssetKey) String() string
String implements Stringer; returns the asset and Channel name but no pairs
type IgnoringPairsKey ¶
type IgnoringPairsKey struct {
*Subscription
}
IgnoringPairsKey is a key type for finding subscriptions to group together for requests
func (IgnoringPairsKey) GetSubscription ¶
func (k IgnoringPairsKey) GetSubscription() *Subscription
GetSubscription returns the underlying subscription
func (IgnoringPairsKey) Match ¶
func (k IgnoringPairsKey) Match(eachKey MatchableKey) bool
Match implements MatchableKey
func (IgnoringPairsKey) String ¶
func (k IgnoringPairsKey) String() string
String implements Stringer; returns the asset and Channel name but no pairs
type List ¶
type List []*Subscription
List is a container of subscription pointers
func (List) ExpandTemplates ¶
ExpandTemplates returns a list of Subscriptions with Template expanded May be called on already expanded subscriptions: Passes $s through unprocessed if QualifiedChannel is already populated Calls e.GetSubscriptionTemplate to find a template for each subscription Filters out Authenticated subscriptions if !e.CanUseAuthenticatedEndpoints See README.md for more details
func (List) GroupByPairs ¶
GroupByPairs groups subscriptions which have the same Pairs
func (List) GroupPairs ¶
GroupPairs groups subscriptions which are identical apart from the Pairs The returned List contains cloned Subscriptions, and the original Subscriptions are left alone
func (List) QualifiedChannels ¶
QualifiedChannels returns a sorted list of all the qualified Channels in the list
type MatchableKey ¶
type MatchableKey interface { Match(MatchableKey) bool GetSubscription() *Subscription String() string }
MatchableKey interface should be implemented by Key types which want a more complex matching than a simple key equality check The Subscription method allows keys to compare against keys of other types
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a container of subscription pointers
func NewStore ¶
func NewStore() *Store
NewStore creates a ready to use store and should always be used
func NewStoreFromList ¶
NewStoreFromList creates a Store from a List
func (*Store) Add ¶
func (s *Store) Add(sub *Subscription) error
Add adds a subscription to the store Key can be already set; if omitted EnsureKeyed will be used Errors if it already exists
func (*Store) Diff ¶
Diff returns a list of the added and missing subs from a new list The store Diff is invoked upon is read-lock protected The new store is assumed to be a new instance and enjoys no locking protection
func (*Store) Get ¶
func (s *Store) Get(key any) *Subscription
Get returns a pointer to a subscription or nil if not found If the key passed in is a Subscription then its Key will be used; which may be a pointer to itself. If key implements MatchableKey then key.Match will be used; Note that *Subscription implements MatchableKey
type Subscription ¶
type Subscription struct { Enabled bool `json:"enabled"` Key any `json:"-"` Channel string `json:"channel,omitempty"` Pairs currency.Pairs `json:"pairs,omitempty"` Asset asset.Item `json:"asset,omitempty"` Params map[string]any `json:"params,omitempty"` Interval kline.Interval `json:"interval,omitempty"` Levels int `json:"levels,omitempty"` Authenticated bool `json:"authenticated,omitempty"` QualifiedChannel string `json:"-"` // contains filtered or unexported fields }
Subscription container for streaming subscriptions
func (*Subscription) AddPairs ¶
func (s *Subscription) AddPairs(pairs ...currency.Pair)
AddPairs does what it says on the tin safely for concurrency
func (*Subscription) Clone ¶
func (s *Subscription) Clone() *Subscription
Clone returns a copy of a subscription Key is set to nil, because most Key types contain a pointer to the subscription, and because the clone isn't added to the store yet QualifiedChannel is not copied because it's expected that the contributing fields will be changed Users should allow a default key to be assigned on AddSubscription or can SetKey as necessary
func (*Subscription) EnsureKeyed ¶
func (s *Subscription) EnsureKeyed() any
EnsureKeyed returns the subscription key If no key exists then ExactKey will be used
func (*Subscription) SetKey ¶
func (s *Subscription) SetKey(key any)
SetKey does what it says on the tin safely for concurrency
func (*Subscription) SetPairs ¶
func (s *Subscription) SetPairs(pairs currency.Pairs)
SetPairs does what it says on the tin safely for concurrency
func (*Subscription) SetState ¶
func (s *Subscription) SetState(state State) error
SetState sets the subscription state Errors if already in that state or the new state is not valid
func (*Subscription) State ¶
func (s *Subscription) State() State
State returns the subscription state
func (*Subscription) String ¶
func (s *Subscription) String() string
String implements Stringer, and aims to informatively and uniquely identify a subscription for errors and information returns a string of the subscription key by delegating to MatchableKey.String() when possible If the key is not a MatchableKey then both the key and an ExactKey.String() will be returned; e.g. 1137: spot MyTrades