orchestrator

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BundleFromMain

func BundleFromMain(main string) scenario.AIBundle

Example of a richer bundle-aware helper (used by advanced scenarios in later PRs). The basic path (LuaCode string) is primary; bundles are accepted in launch_group.

Types

type BotAssignment

type BotAssignment struct {
	NodeAddress   string `json:"node_address"`
	BotID         string `json:"bot_id"`
	AccountName   string `json:"account_name"`
	Password      string `json:"password"`
	CharacterName string `json:"character_name"`
	Race          uint8  `json:"race"`
	Class         uint8  `json:"class"`
	Faction       string `json:"faction,omitempty"` // "alliance" | "horde" - for Orgrimmar siege and similar
}

BotAssignment represents a bot assigned to a node.

type BotNodeResult

type BotNodeResult struct {
	BotID  string `json:"bot_id"`
	Status string `json:"status"`
	Level  uint32 `json:"level"`
	Kills  int    `json:"kills"`
	Deaths int    `json:"deaths"`
	Error  string `json:"error,omitempty"`
}

BotNodeResult is the result from a single bot on a node.

type Config

type Config struct {
	// Database connection in MySQL DSN format: user:pass@tcp(host:port)/dbname
	AuthDBDSN       string `json:"auth_db_dsn"`
	WorldDBDSN      string `json:"world_db_dsn"`
	CharactersDBDSN string `json:"characters_db_dsn"`

	// Auth server address for bot connections
	AuthServerAddr string `json:"auth_server_addr"`

	// List of node addresses (bot runner HTTP endpoints)
	NodeAddresses []string `json:"node_addresses"`

	// Account settings
	AccountPrefix   string `json:"account_prefix"`
	AccountPassword string `json:"account_password"`
	NumBots         int    `json:"num_bots"`

	// Pathfinding
	DataDir            string `json:"data_dir"` // root dir with mmaps/, maps/, vmaps/
	PathfindingAddress string `json:"pathfinding_address"`

	// Bot defaults
	DefaultRace  uint8  `json:"default_race"`
	DefaultClass uint8  `json:"default_class"`
	DefaultMode  string `json:"default_mode"`
	DungeonName  string `json:"dungeon_name"`
	LuaScript    string `json:"lua_script"`
	LuaCode      string `json:"lua_code"` // inline code for scenarios

	// AIBundle support for richer scenario AI distribution
	AIBundle scenario.AIBundle `json:"ai_bundle"`

	// When true (orchestrator default), bots will delete existing characters
	// on the account before creating the target one.
	DeleteExistingCharacters bool `json:"delete_existing_characters"`

	// Rate limiting for spawning bots (to avoid overwhelming auth/world servers)
	// Spawn at most SpawnRateLimit bots per SpawnRateInterval.
	// Example: 100 bots per 2 seconds.
	SpawnRateLimit    int           `json:"spawn_rate_limit"`
	SpawnRateInterval time.Duration `json:"spawn_rate_interval"`

	// Whether launched bots should speak their AI decisions in /say (for debugging).
	LogDecisionsToChat bool `json:"log_decisions_to_chat"`

	// DisableTargetCache tells launched bots to skip the findBestTarget short cache.
	DisableTargetCache bool `json:"disable_target_cache"`

	// Validation tooling flags. These must default false so large-scale load tests have
	// no measurable overhead from validation features.
	ValidationMode      bool   `json:"validation_mode"`
	ValidationLogPath   string `json:"validation_log"`
	EnablePacketTrace   bool   `json:"enable_packet_trace"`
	EnableDetailedAuras bool   `json:"enable_detailed_auras"`
}

Config holds orchestrator configuration.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a config with sensible defaults for AzerothCore.

type NodeLaunchRequest

type NodeLaunchRequest struct {
	BotID               string            `json:"bot_id"`
	Username            string            `json:"username"`
	Password            string            `json:"password"`
	AuthServer          string            `json:"auth_server"`
	CharacterName       string            `json:"character_name"`
	Race                uint8             `json:"race"`
	Class               uint8             `json:"class"`
	Mode                string            `json:"mode"`
	DungeonName         string            `json:"dungeon_name"`
	DataDir             string            `json:"data_dir"`
	PathfindingAddr     string            `json:"pathfinding_addr"`
	LuaScript           string            `json:"lua_script"`
	LuaCode             string            `json:"lua_code"`
	AIBundle            scenario.AIBundle `json:"ai_bundle"`
	DeleteExistingChars bool              `json:"delete_existing_chars"`
	LogDecisionsToChat  bool              `json:"log_decisions_to_chat"`
	DisableTargetCache  bool              `json:"disable_target_cache"`

	// Validation flags (propagated only when doing quality validation runs)
	ValidationMode      bool   `json:"validation_mode"`
	ValidationLogPath   string `json:"validation_log"`
	EnablePacketTrace   bool   `json:"enable_packet_trace"`
	EnableDetailedAuras bool   `json:"enable_detailed_auras"`
}

NodeLaunchRequest is what the orchestrator sends to a node to launch a bot. Matches/extends the one in server/ for wire compatibility. Includes LuaCode and AIBundle for scenario support.

type Orchestrator

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

Orchestrator manages account creation and bot distribution.

func NewOrchestrator

func NewOrchestrator(config Config) (*Orchestrator, error)

NewOrchestrator creates and initializes an orchestrator.

func (*Orchestrator) Close

func (o *Orchestrator) Close()

Close releases resources.

func (*Orchestrator) CollectResults

func (o *Orchestrator) CollectResults() []BotNodeResult

CollectResults queries all nodes for bot status.

func (*Orchestrator) LaunchBots

func (o *Orchestrator) LaunchBots(assignments []BotAssignment) error

LaunchBots sends bot configurations to all nodes (remote). Supports LuaCode/AIBundle from config.

func (*Orchestrator) LaunchLocal

func (o *Orchestrator) LaunchLocal(assignments []BotAssignment) ([]*bot.Bot, error)

LaunchLocal runs bots directly in-process using the bot package (for no-nodes case or local dev).

func (*Orchestrator) LaunchWithRateLimit

func (o *Orchestrator) LaunchWithRateLimit(assignments []BotAssignment, launchFn func(BotAssignment) error) error

LaunchWithRateLimit executes the given launch function for each assignment, throttling so that at most SpawnRateLimit bots are started per SpawnRateInterval.

func (*Orchestrator) PrepareAccounts

func (o *Orchestrator) PrepareAccounts() ([]BotAssignment, error)

PrepareAccounts creates or reuses bot accounts and grants GM rights. DB operations are skipped if no authDB connection (optional DB).

func (*Orchestrator) RunScenario

func (o *Orchestrator) RunScenario(path string) error

RunScenario loads and executes a Lua scenario script. Scripts may imperatively call orch.prepare_accounts(), orch.launch_group(...), orch.sleep etc. or return a plan table (future richer handling).

func (*Orchestrator) UpdateLuaScripts

func (o *Orchestrator) UpdateLuaScripts(luaCode string) error

UpdateLuaScripts sends a Lua script update to all running bots via their nodes.

type ScenarioHost

type ScenarioHost struct {
	L *lua.State
	// contains filtered or unexported fields
}

ScenarioHost provides the Lua-driven scenario execution surface for the orchestrator. It is intentionally small for basic scenario Lua host.

func NewScenarioHost

func NewScenarioHost(o *Orchestrator) *ScenarioHost

NewScenarioHost wraps an existing orchestrator for running scenario scripts.

func (*ScenarioHost) RunFile

func (h *ScenarioHost) RunFile(path string) error

RunFile executes the given scenario Lua file using the host's registered API surface. This satisfies the requirement for azghost orchestrator + basic RunScenario.

type TestResult

type TestResult struct {
	StartTime  time.Time       `json:"start_time"`
	EndTime    time.Time       `json:"end_time"`
	BotResults []BotNodeResult `json:"bot_results"`
	TotalBots  int             `json:"total_bots"`
	Errors     int             `json:"errors"`
}

TestResult holds the aggregate result of a load test.

Jump to

Keyboard shortcuts

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