executor

package
v0.1.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

README

pkg/controller/executor

Executor component - orchestrates reconciliation cycles.

Overview

Stage 5 component that coordinates Renderer, Validator, and Deployer components via event subscriptions. It observes the reconciliation pipeline and publishes lifecycle events for observability.

Quick Start

import "haptic/pkg/controller/executor"

executor := executor.New(bus, logger)
go executor.Start(ctx)

Events

Subscribes To
  • ReconciliationTriggeredEvent: Starts reconciliation cycle
  • TemplateRenderedEvent: Template rendering completed successfully
  • TemplateRenderFailedEvent: Template rendering failed
  • ValidationCompletedEvent: Configuration validation passed
  • ValidationFailedEvent: Configuration validation failed
Publishes
  • ReconciliationStartedEvent: Reconciliation cycle begins
  • ReconciliationCompletedEvent: Reconciliation cycle completes successfully
  • ReconciliationFailedEvent: Reconciliation cycle failed at render or validation stage

License

See main repository for license information.

Documentation

Overview

Package executor implements the Executor component that orchestrates reconciliation cycles by coordinating pure components.

The Executor is a key component in Stage 5 of the controller startup sequence. It subscribes to reconciliation trigger events, orchestrates pure components (Renderer, Validator, Deployer), and publishes events at each stage for observability and coordination.

Index

Constants

View Source
const (
	// ComponentName is the unique identifier for this component.
	ComponentName = "executor"

	// EventBufferSize is the size of the event subscription buffer.
	EventBufferSize = 50
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

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

Executor implements the reconciliation orchestrator component.

It subscribes to ReconciliationTriggeredEvent and orchestrates the reconciliation workflow:

  1. Render templates with current resource state
  2. Validate generated configuration
  3. Deploy validated configuration to HAProxy instances

The component publishes events at each stage for observability:

  • ReconciliationStartedEvent: Reconciliation cycle begins
  • TemplateRenderedEvent: Template rendering completes
  • ValidationCompletedEvent: Validation succeeds
  • DeploymentCompletedEvent: Deployment succeeds
  • ReconciliationCompletedEvent: Full cycle completes
  • ReconciliationFailedEvent: Any stage fails

func New

func New(eventBus *busevents.EventBus, logger *slog.Logger) *Executor

New creates a new Executor component.

Parameters:

  • eventBus: The EventBus for subscribing to events and publishing results
  • logger: Structured logger for component logging

Returns:

  • A new Executor instance ready to be started

func (*Executor) Name

func (e *Executor) Name() string

Name returns the unique identifier for this component. Implements the lifecycle.Component interface.

func (*Executor) Start

func (e *Executor) Start(ctx context.Context) error

Start begins the executor's event loop.

This method blocks until the context is cancelled or an error occurs. The component is already subscribed to the EventBus (subscription happens in New()), so this method only processes events:

  • ReconciliationTriggeredEvent: Starts orchestration of reconciliation cycle
  • TemplateRenderedEvent: Handles successful template rendering
  • TemplateRenderFailedEvent: Handles template rendering failures
  • ValidationCompletedEvent: Handles successful validation
  • ValidationFailedEvent: Handles validation failures

The component runs until the context is cancelled, at which point it performs cleanup and returns.

Parameters:

  • ctx: Context for cancellation and lifecycle management

Returns:

  • nil when context is cancelled (graceful shutdown)
  • Error only in exceptional circumstances

Jump to

Keyboard shortcuts

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