Reorganized structure, seperating implementations from core logic
This commit is contained in:
2
pkg/data/coordinator/coordinator.go
Normal file
2
pkg/data/coordinator/coordinator.go
Normal file
@@ -0,0 +1,2 @@
|
||||
// Package coordinator ...
|
||||
package coordinator
|
||||
9
pkg/data/descriptor.go
Normal file
9
pkg/data/descriptor.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package data
|
||||
|
||||
type Descriptor struct {
|
||||
Type string
|
||||
Key string
|
||||
Schema string
|
||||
Attributes map[string]string
|
||||
Tags []string
|
||||
}
|
||||
18
pkg/data/egress.go
Normal file
18
pkg/data/egress.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package data
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type Egress interface {
|
||||
Name() string
|
||||
Configure(cfg map[string]any) error
|
||||
Connect(ctx context.Context, actions EgresActions) error
|
||||
Disconnect(ctx context.Context) error
|
||||
}
|
||||
|
||||
type EgresActions interface {
|
||||
Subscribe(ctx context.Context, namespace string, id uuid.UUID) (<-chan Envelope, func(), error)
|
||||
}
|
||||
13
pkg/data/envelope.go
Normal file
13
pkg/data/envelope.go
Normal file
@@ -0,0 +1,13 @@
|
||||
// Package data ...
|
||||
package data
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Envelope struct {
|
||||
SendTime time.Time
|
||||
|
||||
Descriptor Descriptor
|
||||
Payload any
|
||||
}
|
||||
12
pkg/data/events/bar.go
Normal file
12
pkg/data/events/bar.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package events
|
||||
|
||||
import "time"
|
||||
|
||||
type Bar struct {
|
||||
Open float64
|
||||
High float64
|
||||
Low float64
|
||||
Close float64
|
||||
Volume float64
|
||||
Interval time.Duration
|
||||
}
|
||||
6
pkg/data/events/custom.go
Normal file
6
pkg/data/events/custom.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package events
|
||||
|
||||
type Custom struct {
|
||||
Bytes []byte
|
||||
ContentType string
|
||||
}
|
||||
22
pkg/data/events/domain.go
Normal file
22
pkg/data/events/domain.go
Normal file
@@ -0,0 +1,22 @@
|
||||
// Package events ...
|
||||
package events
|
||||
|
||||
type DataType uint8
|
||||
|
||||
const (
|
||||
TradeType DataType = iota
|
||||
QuoteType
|
||||
BarType
|
||||
MBPDeltaType
|
||||
MBPSnapshotType
|
||||
MBODeltaType
|
||||
MBOSnapshotType
|
||||
CustomType
|
||||
)
|
||||
|
||||
type Side uint8
|
||||
|
||||
const (
|
||||
Bid Side = iota
|
||||
Ask
|
||||
)
|
||||
20
pkg/data/events/mbodelta.go
Normal file
20
pkg/data/events/mbodelta.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package events
|
||||
|
||||
type MBODelta struct {
|
||||
Operation MBOOrderOp
|
||||
OrderID string
|
||||
Side Side
|
||||
Price float64
|
||||
Size float64
|
||||
IsMaker bool
|
||||
Seq uint64
|
||||
ParentID string
|
||||
}
|
||||
|
||||
type MBOOrderOp uint8
|
||||
|
||||
const (
|
||||
OrderAdd MBOOrderOp = iota
|
||||
OrderMod
|
||||
OrderDel
|
||||
)
|
||||
14
pkg/data/events/mbosnapshot.go
Normal file
14
pkg/data/events/mbosnapshot.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package events
|
||||
|
||||
type MBOSnapshot struct {
|
||||
Orders []OrderEntry
|
||||
Seq uint64
|
||||
}
|
||||
|
||||
type OrderEntry struct {
|
||||
OrderID string
|
||||
Side Side
|
||||
Price float64
|
||||
Size float64
|
||||
IsMaker bool
|
||||
}
|
||||
8
pkg/data/events/mbpdelta.go
Normal file
8
pkg/data/events/mbpdelta.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package events
|
||||
|
||||
type MBPDelta struct {
|
||||
Side Side
|
||||
Price float64
|
||||
Size float64
|
||||
Seq uint64
|
||||
}
|
||||
13
pkg/data/events/mbpsnapshot.go
Normal file
13
pkg/data/events/mbpsnapshot.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package events
|
||||
|
||||
type MBPSnapshot struct {
|
||||
Bids []PriceLevel
|
||||
Asks []PriceLevel
|
||||
Depth int
|
||||
Seq uint64
|
||||
}
|
||||
|
||||
type PriceLevel struct {
|
||||
Price float64
|
||||
Size float64
|
||||
}
|
||||
8
pkg/data/events/quote.go
Normal file
8
pkg/data/events/quote.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package events
|
||||
|
||||
type Quote struct {
|
||||
BidPrice float64
|
||||
BidSize float64
|
||||
AskPrice float64
|
||||
AskSize float64
|
||||
}
|
||||
16
pkg/data/events/trade.go
Normal file
16
pkg/data/events/trade.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package events
|
||||
|
||||
type Trade struct {
|
||||
Price float64
|
||||
Qty float64
|
||||
Aggressor AggressorSide
|
||||
TradeID string
|
||||
}
|
||||
|
||||
type AggressorSide uint8
|
||||
|
||||
const (
|
||||
AggUnknown AggressorSide = iota
|
||||
AggBuy
|
||||
AggSell
|
||||
)
|
||||
34
pkg/data/ingress.go
Normal file
34
pkg/data/ingress.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package data
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type Ingress interface {
|
||||
Name() string
|
||||
Configure(cfg map[string]any) error
|
||||
Connect(ctx context.Context, actions IngressActions) error
|
||||
Disconnect(ctx context.Context) error
|
||||
}
|
||||
|
||||
type IngressActions interface {
|
||||
Emit(namespace string, id uuid.UUID, envelope Envelope) error
|
||||
EmitBatch(namespace string, id uuid.UUID, envelopes []Envelope) error
|
||||
}
|
||||
|
||||
type LiveIngress interface {
|
||||
Subscribe(ctx context.Context, key ...string) error
|
||||
Unsubscribe(ctx context.Context, key ...string) error
|
||||
ListAvailableKeys(ctx context.Context) []string
|
||||
IsValidKey(ctx context.Context, key string) bool
|
||||
}
|
||||
|
||||
type HistoricalIngress interface {
|
||||
Fetch(ctx context.Context, key string, start time.Time, end time.Time) ([]Envelope, error)
|
||||
ListAvailableKeys(ctx context.Context) []string
|
||||
IsValidKey(ctx context.Context, key string) bool
|
||||
// some other method that gives the avalible time period for a key
|
||||
}
|
||||
14
pkg/data/processor.go
Normal file
14
pkg/data/processor.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package data
|
||||
|
||||
import "context"
|
||||
|
||||
type Processor interface {
|
||||
Name() string
|
||||
Configure(cfg map[string]any) error
|
||||
Run(ctx context.Context, actions ProcessorActions) error
|
||||
}
|
||||
|
||||
type ProcessorActions interface {
|
||||
IngressActions
|
||||
EgresActions
|
||||
}
|
||||
1
pkg/data/registry.go
Normal file
1
pkg/data/registry.go
Normal file
@@ -0,0 +1 @@
|
||||
package data
|
||||
2
pkg/data/router/router.go
Normal file
2
pkg/data/router/router.go
Normal file
@@ -0,0 +1,2 @@
|
||||
// Package router ...
|
||||
package router
|
||||
Reference in New Issue
Block a user