Refacto FileStore to JSONStore
Generate check / check-changes (pull_request) Successful in 3s
Quality / check-changes (pull_request) Successful in 2s
Generate check / verify-generate (pull_request) Successful in 32s
Quality / static-checks (pull_request) Successful in 55s
Quality / run-tests (pull_request) Successful in 52s

This commit is contained in:
2026-09-06 18:16:26 +01:00
parent e5961c0dff
commit 6c06dbdd59
6 changed files with 132 additions and 76 deletions
+7 -6
View File
@@ -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