node

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// IdleStrategyGosched yields to the Go scheduler on every idle iteration.
	IdleStrategyGosched = "gosched"
	// IdleStrategySpin busy-spins a bounded number of idle iterations
	// before yielding.
	IdleStrategySpin = "spin"

	// DefaultSpinBudget bounds a spin-strategy busy loop. At ~ns-scale ring
	// probes this is a few microseconds of spinning per yield.
	DefaultSpinBudget = 4096
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Engine   EngineConfig   `yaml:"engine"`
	Dispatch DispatchConfig `yaml:"dispatch"`
}

Config contains node-level configuration.

type DispatchConfig

type DispatchConfig struct {
	// IdleStrategy is "gosched" (default) or "spin".
	//   gosched: yield to the Go scheduler whenever the loop finds no work.
	//     Cooperative; correct on shared cores.
	//   spin: busy-spin SpinBudget idle iterations before yielding once.
	//     Minimizes wake-up latency; requires a dedicated core
	//     (see docs/DEPLOYMENT.md).
	IdleStrategy string `yaml:"idle_strategy"`
	// SpinBudget is the number of consecutive idle iterations a spin-strategy
	// loop performs before it yields to the scheduler. 0 selects
	// DefaultSpinBudget. Ignored for the gosched strategy.
	SpinBudget int `yaml:"spin_budget"`
}

DispatchConfig controls the dispatch-loop goroutine (P2-4). The loop is always pinned to one OS thread (runtime.LockOSThread); this selects what it does when idle.

type EngineConfig

type EngineConfig struct {
	Data      data.Config      `yaml:"data"`
	Execution execution.Config `yaml:"execution"`
	Ledger    ledger.Config    `yaml:"ledger"`
	Risk      risk.Config      `yaml:"risk"`
	Strategy  strategy.Config  `yaml:"strategy"`
}

EngineConfig composes all engine configurations.

type Node

type Node struct {
	// contains filtered or unexported fields
}

Node orchestrates all engines and the event loop.

func NewNode

func NewNode(cat *catalog.Catalog) *Node

NewNode creates a new Node with the given catalog.

func (*Node) Cache

func (n *Node) Cache() *cache.Cache

Cache returns the node's Cache.

func (*Node) DataEngine

func (n *Node) DataEngine() *data.Engine

DataEngine returns the data engine.

func (*Node) ExecutionEngine

func (n *Node) ExecutionEngine() *execution.Engine

ExecutionEngine returns the execution engine.

func (*Node) ExecutionRouter

func (n *Node) ExecutionRouter() *adapter.ExecutionRouter

ExecutionRouter returns the execution router.

func (*Node) Init

func (n *Node) Init(config Config, execRouter []adapter.ExecRouterEntry, dataRouter []adapter.DataRouterEntry, tradingMode tradingmode.Mode)

Init initializes the node and all engines from config. execRouter and dataRouter are the top-level adapter configs parsed from YAML. tradingMode gates venue order mutations on the execution router (default paper).

func (*Node) LedgerEngine

func (n *Node) LedgerEngine() *ledger.Engine

LedgerEngine returns the ledger engine.

func (*Node) MsgBus

func (n *Node) MsgBus() *msgbus.MsgBus

MsgBus returns the node's MsgBus.

func (*Node) Run

func (n *Node) Run(ctx context.Context)

Run starts the event loop and blocks until context is cancelled, then performs graceful shutdown.

The dispatch goroutine is pinned to its OS thread (P2-4) so the Go scheduler cannot migrate it across cores; combined with the taskset / isolcpus recipe in docs/DEPLOYMENT.md this gives the loop a stable, cache-warm core. The idle strategy is configurable: cooperative Gosched (default) or a bounded busy-spin for latency-critical deployments on a dedicated core.

func (*Node) Start

func (n *Node) Start(ctx context.Context)

Start connects engines and starts all actors.

Jump to

Keyboard shortcuts

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