source

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2025 License: Unlicense Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadUpgrade = errors.New("matt::chasm::source: bad upgrade")
	ErrBadRead    = errors.New("matt::chasm::source: bad read")
)

Functions

This section is empty.

Types

type Ask added in v0.15.1

type Ask uint64

func (Ask) After added in v0.15.1

func (this Ask) After(that Ask) bool

func (Ask) Before added in v0.15.1

func (this Ask) Before(that Ask) bool

func (Ask) Compare added in v0.15.1

func (this Ask) Compare(that Ask) int

func (Ask) Equal added in v0.15.1

func (this Ask) Equal(that Ask) bool

type BatchDecodeFunc added in v0.15.0

type BatchDecodeFunc[T core.Event] func(frame []byte, destination []T) (int, bool, error)

type BatchDecoder added in v0.15.0

type BatchDecoder[T core.Event] interface {
	Decode(frame []byte, destination []T) (int, bool, error)
}

type Bid added in v0.15.1

type Bid uint64

func (Bid) After added in v0.15.1

func (this Bid) After(that Bid) bool

func (Bid) Before added in v0.15.1

func (this Bid) Before(that Bid) bool

func (Bid) Compare added in v0.15.1

func (this Bid) Compare(that Bid) int

func (Bid) Equal added in v0.15.1

func (this Bid) Equal(that Bid) bool

type BookCodec added in v0.15.0

type BookCodec interface {
	Proto
	UnitDecoder[core.BookEvent]
}

func NewBookCodec added in v0.15.0

func NewBookCodec(
	endpoint endpoint,
	sub, unsub ProtoMsgFunc,
	decode LossyDecodeFunc[core.BookEvent, OrderBook],
) BookCodec

type CandleCodec added in v0.15.0

type CandleCodec interface {
	Proto
	SinkDecoder[core.CandleEvent]
}

func NewCandleCodec added in v0.15.0

func NewCandleCodec(
	endpoint endpoint,
	sub, unsub ProtoMsgFunc,
	sink SinkFunc[core.CandleEvent, CandleStore],
	try SinkTryFunc[core.CandleEvent, CandleStore],
) CandleCodec

type CandleStore added in v0.15.1

type CandleStore struct {
	Interval [10]int64
	New      [10]bool
	Candle   [10]core.CandleEvent
	// contains filtered or unexported fields
}

func (*CandleStore) Lock added in v0.16.0

func (s *CandleStore) Lock()

func (*CandleStore) TryLock added in v0.16.0

func (s *CandleStore) TryLock() bool

func (*CandleStore) Unlock added in v0.16.0

func (s *CandleStore) Unlock()

type DecodeKeyFunc

type DecodeKeyFunc func(raw []byte) []core.Key

TODO: we should be returning an error

type KeyGetter

type KeyGetter interface {
	Online() []core.Key
	Offline() []core.Key
	All() []core.Key
}

func NewKeyGetter

func NewKeyGetter(online, offline, all DecodeKeyFunc, req http.Request) KeyGetter

type LossyDecodeFunc added in v0.15.0

type LossyDecodeFunc[T core.Event, S WorkingState] func(state *S, frame []byte) (T, bool, error)

type OrderBook added in v0.16.0

type OrderBook struct {
	Bid kit.LeakyHeap[Bid]
	Ask kit.LeakyHeap[Ask]
	// contains filtered or unexported fields
}

func (*OrderBook) Lock added in v0.16.0

func (s *OrderBook) Lock()

func (*OrderBook) TryLock added in v0.16.0

func (s *OrderBook) TryLock() bool

func (*OrderBook) Unlock added in v0.16.0

func (s *OrderBook) Unlock()

type Proto

type Proto interface {
	Endpoint() string
	Subscribe(key core.Key) []byte
	Unsubscribe(key core.Key) []byte
}

type ProtoMsgFunc added in v0.15.0

type ProtoMsgFunc func(key core.Key) []byte

type Reader

type Reader[T core.Event] interface {
	Open() error
	Close() error
	Read() (T, bool)
	Next() error
}

type SinkDecoder added in v0.14.1

type SinkDecoder[T core.Event] interface {
	Sink(key core.Key, frame []byte) (T, bool, error)
	Try(key core.Key) (T, bool, error)
}

type SinkFunc added in v0.15.0

type SinkFunc[T core.Event, S WorkingState] func(state *S, key core.Key, frame []byte) (T, bool, error)

type SinkTryFunc added in v0.15.0

type SinkTryFunc[T core.Event, S WorkingState] func(state *S, key core.Key) (T, bool, error)

type Source

type Source interface {
	Symbol(key core.Key) Reader[core.SymbolEvent]
	Book(key core.Key) Reader[core.BookEvent]
	Candle(key core.Key) Reader[core.CandleEvent]
	Trade(key core.Key) Reader[core.TradeEvent]
	Get() KeyGetter
}

func NewSource

func NewSource(
	origin string,
	symbol SymbolCodec,
	book BookCodec,
	trade TradeCodec,
	candle CandleCodec,
	getter KeyGetter,
) Source

type SymbolCodec added in v0.15.0

type SymbolCodec interface {
	Proto
	BatchDecoder[core.SymbolEvent]
}

func NewSymbolCodec added in v0.15.0

func NewSymbolCodec(
	endpoint endpoint,
	sub, unsub ProtoMsgFunc,
	decode BatchDecodeFunc[core.SymbolEvent],
) SymbolCodec

type TradeCodec added in v0.15.0

type TradeCodec interface {
	Proto
	BatchDecoder[core.TradeEvent]
}

func NewTradeCodec added in v0.15.0

func NewTradeCodec(
	endpoint endpoint,
	sub, unsub ProtoMsgFunc,
	decode BatchDecodeFunc[core.TradeEvent],
) TradeCodec

type UnitDecoder added in v0.15.0

type UnitDecoder[T core.Event] interface {
	Decode(key core.Key, frame []byte) (T, bool, error)
}

type WorkingState added in v0.16.0

type WorkingState interface {
	OrderBook | CandleStore
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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