websockets

package
v0.0.0-...-5fd8545 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	INIT_FLUSH_COUNT  = 1
	MAX_FLUSH_ATTEMPT = 3
)
View Source
const (
	MessageDisconnect = "Disconnect"
	MessageConnect    = "Connect"
)

Variables

View Source
var (

	// TODO(kano): - extend Logger to application name to prefix all output with service name => in this case websockets.
	Logger                = NewLogger()
	MAX_BYTE_LENGTH_FLUSH = 128
)
View Source
var TestChannel *chan Payload

Functions

func ConnectionManagerInit

func ConnectionManagerInit(connLimit int) (*connectionManager, error)

func Init

func Init(ctx context.Context, connectionLimit int) (jobs.NamedFunction, error)

Setups websockets and return an error if setup fails. If error is nil, websockets are started in the background. Websockets can be stopped by canceling the context.

func NewLogger

func NewLogger() *logrus.Logger

TODO(muninn): This is the last dependency of logrus, migrate to midlog.

func NotifyTest

func NotifyTest(p Payload)

TODO(kano): change unit test to connect through real websockets, then delete this.

func WsHandler

func WsHandler(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

Types

type Instruction

type Instruction struct {
	Message string   // Disconnect or Connect
	Assets  []string // valid Assets supported within our pools
}

Instruction to subscribe and unsubscribe from WS

type Payload

type Payload struct {
	Price string
	Asset string // Asset supported within our pools
}

Payload what we send to clients to convey price updates

func (*Payload) ToString

func (p *Payload) ToString() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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