Reviewed-on: #30 Co-authored-by: Natercio Moniz <[email protected]>
This commit was merged in pull request #30.
This commit is contained in:
+7
-6
@@ -2,12 +2,13 @@ package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
// StateVersion is the schema version of the persisted State struct.
|
||||
const StateVersion = "1"
|
||||
const StateVersion = "2"
|
||||
|
||||
// State is the platform-agnostic representation of the buy-queue state that is
|
||||
// written to disk after a successful run and reloaded on the next run.
|
||||
@@ -21,20 +22,20 @@ type State struct {
|
||||
// Record-specific data is kept as opaque bytes so the internal package does
|
||||
// not need to know about any broker package's concrete Record type.
|
||||
type persistedFiller struct {
|
||||
RecordData []byte `json:"record_data"`
|
||||
RecordData json.RawMessage `json:"record_data"`
|
||||
Quantity decimal.Decimal `json:"quantity"`
|
||||
Price decimal.Decimal `json:"price"`
|
||||
Filled decimal.Decimal `json:"filled"`
|
||||
}
|
||||
|
||||
// RecordEncoder encodes a Record into its broker-specific byte representation.
|
||||
// RecordEncoder encodes a Record into its broker-specific JSON representation.
|
||||
type RecordEncoder interface {
|
||||
MarshalRecord(context.Context, Record) ([]byte, error)
|
||||
MarshalRecord(context.Context, Record) (json.RawMessage, error)
|
||||
}
|
||||
|
||||
// RecordDecoder decodes broker-specific bytes back into a Record.
|
||||
// RecordDecoder decodes broker-specific JSON back into a Record.
|
||||
type RecordDecoder interface {
|
||||
UnmarshalRecord(context.Context, []byte) (Record, error)
|
||||
UnmarshalRecord(context.Context, json.RawMessage) (Record, error)
|
||||
}
|
||||
|
||||
// RecordSerializer composes encoding and decoding of Records. Broker packages
|
||||
|
||||
Reference in New Issue
Block a user