reloader

package
v1.27.1 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package reloader provides interfaces and implementations for running local development processes with hot-reload capabilities.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnknownType is returned when trying to create a reloader with an unknown type.
	ErrUnknownType = errors.New("unknown reloader type")

	// ErrRunFailed is returned when a reloader run operation fails.
	ErrRunFailed = errors.New("reloader run failed")

	// ErrStatusFailed is returned when unable to determine reloader status.
	ErrStatusFailed = errors.New("failed to get reloader status")

	// ErrTargetNotFound is returned when the target resource doesn't exist.
	ErrTargetNotFound = errors.New("target resource not found")
)

Functions

func ListTypes

func ListTypes() []string

ListTypes returns a list of all registered reloader types.

func Register

func Register(reloaderType string, factory ManagerFactory)

Register registers a reloader manager factory for a given type. This function is typically called in init() functions of reloader implementations.

Types

type Manager

type Manager interface {
	// Type returns the reloader type that this manager handles (e.g., "mirror", "skaffold").
	Type() string

	// Run runs the reloader processes, blocking until the context is cancelled.
	// This method should:
	//   - Perform any pre-run setup (e.g., creating deployment copies)
	//   - Start all configured processes
	//   - Monitor processes for crashes and restart as needed
	//   - Clean up on context cancellation (e.g., removing deployment copies)
	//
	// Returns an error if:
	//   - Unable to start processes
	//   - Repository directory doesn't exist
	//   - Target resources don't exist (for mirrord)
	Run(ctx context.Context, reloaderConfig *v2.ReloaderConfig, caproniConfig *v2.CaproniConfig) error

	// Status returns the current status of the reloader.
	// Returns an error if unable to determine reloader state.
	Status(ctx context.Context, reloaderConfig *v2.ReloaderConfig, caproniConfig *v2.CaproniConfig) (*Status, error)

	// Validate validates the reloader configuration and referenced files.
	// Returns nil if valid, or an error describing validation failures.
	// Files in uncloned repository directories should not cause validation to fail.
	Validate(reloaderConfig *v2.ReloaderConfig, caproniConfig *v2.CaproniConfig) error
}

Manager defines the interface for managing local development processes. Implementations are responsible for running processes with hot-reload capabilities using specific strategies (e.g., mirrord, skaffold).

func NewManager

func NewManager(reloaderType string) (Manager, error)

NewManager creates a new reloader manager for the given type. Returns an error if the type is not registered.

type ManagerFactory

type ManagerFactory func() Manager

ManagerFactory is a function that creates a new reloader manager.

type State

type State string

State represents the current state of a reloader.

const (
	// StateNotDeployed indicates the target deployment doesn't exist.
	StateNotDeployed State = "not-deployed"

	// StateNotReady indicates the reloader cannot run (e.g., target resource missing).
	StateNotReady State = "not-ready"

	// StateReady indicates the reloader is ready to run.
	StateReady State = "ready"

	// StateFailed indicates the reloader failed.
	StateFailed State = "failed"
)

type Status

type Status struct {
	// State is the current state of the reloader.
	State State

	// Type is the reloader type (e.g., "mirror", "skaffold").
	Type string
}

Status represents the current state of a reloader.

Directories

Path Synopsis
Package mirror implements the reloader manager for mirror reloaders.
Package mirror implements the reloader manager for mirror reloaders.
Package skaffold implements the reloader manager for skaffold reloaders.
Package skaffold implements the reloader manager for skaffold reloaders.

Jump to

Keyboard shortcuts

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