Documentation
¶
Index ¶
- Constants
- Variables
- func CalculateDataSize(t *testing.T, ctx context.Context, dataWriter *DataWriter, timeToCollect int, ...)
- func Subscribe(ctx context.Context, source Source, topic string) (chan []byte, error)
- type CollectorInstance
- type CollectorWorker
- type DataCollector
- type DataWindow
- type DataWriter
- type MessageTimeHash
- type Request
- type Source
- type SourceMetric
- type Summary
Constants ¶
View Source
const ANCHOR_TIME_RANGE_SECONDS = 2
View Source
const WORKER_COUNT = 2
Odd workers look at current. Even workers look ahead? Otherwise I can do a treadmill system.
Variables ¶
View Source
var Sources = []Source{}
The global table with all our sources.
View Source
var SourcesBlockchainRPC = []Source{ { "ethereum-ankr-rpc", joinEthereumRPC, nil, "https://rpc.ankr.com/eth", []string{""}, "", }, { "polygon-ankr-rpc", joinEthereumRPC, nil, "https://rpc.ankr.com/polygon", []string{""}, "", }, }
Should handle these as a separate case, since blockchain information can exactly be consistent from different sources.
View Source
var SourcesCEX = []Source{ { "binance", defaultJoinCEX, panicStubFunctionSeeBodyForExplanation, "wss://stream.binance.com:9443/ws", []string{"btcusdt", "ethusdt", "solusdt"}, "{ \"method\": \"SUBSCRIBE\", \"params\": [ \"{{topic}}@aggTrade\" ], \"id\": 1 }"}, { "coinbase", defaultJoinCEX, panicStubFunctionSeeBodyForExplanation, "wss://ws-feed.pro.coinbase.com", []string{"BTC-USD", "ETH-USD", "BTC-ETH"}, "{\"type\": \"subscribe\", \"product_ids\": [ \"{{topic}}\" ], \"channels\": [ \"ticker\" ]}"}, { "dydx", defaultJoinCEX, panicStubFunctionSeeBodyForExplanation, "wss://api.dydx.exchange/v3/ws", []string{"MATIC-USD", "LINK-USD", "SOL-USD", "ETH-USD", "BTC-USD"}, "{\"type\": \"subscribe\", \"id\": \"{{topic}}\", \"channel\": \"v3_trades\"}", }, { "bybit", defaultJoinCEX, panicStubFunctionSeeBodyForExplanation, "wss://stream.bybit.com/v5/public/spot", []string{"orderbook.50.BTCUSDT", "publicTrade.BTCUSDT", "tickers.BTCUSDT", "kline.M.BTCUSDT"}, `{"op": "subscribe","args": ["{{topic}}"]}`, }, { "okx", defaultJoinCEX, panicStubFunctionSeeBodyForExplanation, "wss://ws.okx.com:8443/ws/v5/business", []string{"sprd-bbo-tbt", "sprd-books5", "sprd-public-trades", "sprd-tickers"}, `{"op": "subscribe","args": [{"channel": "{{topic}}","sprdId": "BTC-USDT_BTC-USDT-SWAP"}]}`, }, }
View Source
var SourcesNFTExchange = []Source{}
Functions ¶
func CalculateDataSize ¶
func CalculateDataSize(t *testing.T, ctx context.Context, dataWriter *DataWriter, timeToCollect int, timeFrameWindowSize int)
Handler to subscribe to each source and symbol & measure data size over a set period from current time.
Types ¶
type CollectorInstance ¶
type CollectorInstance struct {
// contains filtered or unexported fields
}
func NewInstance ¶
func NewInstance(rpInstance *resourcepool.Instance) *CollectorInstance
func (*CollectorInstance) Start ¶
func (ci *CollectorInstance) Start(ctx context.Context)
func (*CollectorInstance) Stop ¶
func (ci *CollectorInstance) Stop()
func (*CollectorInstance) SubmitRequests ¶
type CollectorWorker ¶
type CollectorWorker struct {
// contains filtered or unexported fields
}
type DataCollector ¶
type DataCollector struct {
Source Source
TimeWindow time.Duration
DataWindows map[string]*DataWindow
BusiestWindow *DataWindow
}
func NewDataCollector ¶
func NewDataCollector(source Source, windowTimeSize time.Duration) *DataCollector
type DataWindow ¶
type DataWriter ¶
type DataWriter struct {
// contains filtered or unexported fields
}
func NewDataWriter ¶
func NewDataWriter(filename string) (*DataWriter, error)
func (*DataWriter) Close ¶
func (dw *DataWriter) Close() error
func (*DataWriter) Write ¶
func (dw *DataWriter) Write(data []string) error
type MessageTimeHash ¶
type MessageTimeHash struct {
// contains filtered or unexported fields
}
type Source ¶
type Source struct {
Name string
JoinFunc func(ctx context.Context, source Source, topic string) (chan []byte, <-chan error, error)
ParseFunc func(source Source, data []byte) []byte
ApiURL string // To-do: Add support for multiple endpoints.
Topics []string
Request string
}
Defines a "source" of data, all supported sources are laid out in the Sources array. We opt for this approach over oop for clarity and extensibility.
type SourceMetric ¶
type SourceMetric struct {
// contains filtered or unexported fields
}
func NewSourceMetric ¶
func NewSourceMetric(sourceName string) *SourceMetric
Click to show internal directories.
Click to hide internal directories.