mux

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mux

type Mux struct {
	Err error
	// contains filtered or unexported fields
}

Mux will manage all connections and subscriptions. Will check if subscriptions limit is reached and spawn new connection when that happens. It will also listen to all incomming client messages and reconnect client with all its subscriptions in case of a failure

func New

func New() *Mux

New returns pointer to instance of mux

func (*Mux) Close

func (m *Mux) Close() bool

func (*Mux) IsConnected

func (m *Mux) IsConnected() bool

func (*Mux) Listen

func (m *Mux) Listen(cb func(interface{}, error)) error

Listen accepts a callback func that will get called each time mux receives a message from any of its clients/subscriptions. It should be called last, after all setup calls are made

func (*Mux) Send

func (m *Mux) Send(pld interface{}) error

Send meant for authenticated input, takes payload in form of interface and calls client with it

func (*Mux) Start

func (m *Mux) Start() *Mux

Start creates initial clients for accepting connections

func (*Mux) Subscribe

func (m *Mux) Subscribe(sub event.Subscribe) *Mux

Subscribe - given the details in form of event.Subscribe, subscribes client to public channels. If rate limit is reached, calls itself recursively after 1s with same params

func (*Mux) TransformRaw

func (m *Mux) TransformRaw() *Mux

TransformRaw enables data transformation and mapping to appropriate models before sending it to consumer

func (*Mux) WithAPIKEY

func (m *Mux) WithAPIKEY(key string) *Mux

WithAPIKEY accepts and persists api key

func (*Mux) WithAPISEC

func (m *Mux) WithAPISEC(sec string) *Mux

WithAPISEC accepts and persists api secret

func (*Mux) WithAuthURL

func (m *Mux) WithAuthURL(url string) *Mux

WithAuthURL accepts and persists auth api url

func (*Mux) WithDeadManSwitch

func (m *Mux) WithDeadManSwitch() *Mux

WithDeadManSwitch - when socket is closed, cancel all account orders

func (*Mux) WithPublicURL

func (m *Mux) WithPublicURL(url string) *Mux

WithPublicURL accepts and persists public api url

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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