Documentation
¶
Index ¶
- func ApplyName(a Actor, name string)
- func Register(bus *msgbus.MsgBus, a Actor)
- type Actor
- type ActorBase
- func (a *ActorBase) Clock() *clock.Clock
- func (a *ActorBase) Handle(ev msgbus.Event, bus *msgbus.MsgBus)
- func (a *ActorBase) Log() *zerolog.Logger
- func (a *ActorBase) Name() string
- func (a *ActorBase) OnInit(config map[string]any)
- func (a *ActorBase) OnStart()
- func (a *ActorBase) OnStop()
- func (a *ActorBase) SetClock(c *clock.Clock)
- func (a *ActorBase) SetName(name string)
- func (a *ActorBase) SetTopics(topics []event.Topic)
- func (a *ActorBase) SubscribedTypes() []event.Topic
- type Entry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyName ¶
ApplyName sets the actor's name from the config entry. If name is empty, the actor keeps its default name from construction. This works on any actor that embeds ActorBase (which provides SetName).
func Register ¶
Register is a helper function that registers an Actor with the MsgBus. It creates a handler that calls the actor's Handle method with the MsgBus reference. If a Clock is attached to the MsgBus via SetTicker, it is automatically injected into the actor (available via ActorBase.Clock() in OnStart and Handle).
Types ¶
type Actor ¶
type Actor interface {
// Identity
// Name returns a unique identifier for this actor.
// Used for sequence tracking and debugging.
Name() string
// Event subscription
// SubscribedTypes returns the event types this actor wants to receive.
// Return nil or empty slice to receive all event types.
SubscribedTypes() []event.Topic
// Event handling
// Handle processes an event from the MsgBus.
// The MsgBus reference is provided to allow reading the full event data
// from the appropriate arena based on the event reference, and to send
// commands via the command channel.
Handle(ev msgbus.Event, bus *msgbus.MsgBus)
// Lifecycle methods
// OnInit is called once when the actor is initialized.
OnInit(map[string]any)
// OnStart is called once when the actor is started.
OnStart()
// OnStop is called once when the actor is stopped.
OnStop()
}
Actor is the unified interface for all event-driven components. Both infrastructure actors (OrderBook, EMS) and trading strategies implement this.
Actors are the fundamental building blocks of the trading system: - OrderBook actor handles depth snapshots and updates - EMS actor handles order updates and fills - Strategy actors implement trading logic
type ActorBase ¶
type ActorBase struct {
// contains filtered or unexported fields
}
ActorBase provides a default implementation for the Actor interface. Embed this in infrastructure actors like OrderBook, EMS. For trading strategies, use StrategyBase instead which provides typed callbacks.
func NewActorBase ¶
NewActorBase creates a new ActorBase with the given name and subscribed topics.
func (*ActorBase) Clock ¶
Clock returns the injected Clock instance. Available after actor.Register().
func (*ActorBase) OnStart ¶
func (a *ActorBase) OnStart()
OnStart is a no-op default lifecycle method.
func (*ActorBase) SetClock ¶
SetClock sets the clock on this actor. Called automatically by actor.Register().
func (*ActorBase) SetName ¶
SetName overrides the actor's name and re-initializes its logger with the new name context. This is typically called by the engine after construction to apply the name from config. If name is empty, this is a no-op.
func (*ActorBase) SetTopics ¶
SetTopics overrides the actor's subscribed topics. Typically called from OnInit when topics are configured via YAML.
func (*ActorBase) SubscribedTypes ¶
SubscribedTypes returns the topics this actor handles.