Bootstrap Plugin API Reference

Application bootstrap and validation plugin for Structum Lab.

Structum Bootstrap (structum-bootstrap)

Documentation Python 3.11+ License: Apache-2.0

Structum Bootstrap provides “Fail Fast” mechanisms to validate the execution environment (filesystem, network, environment variables) at application startup.

🚀 Installation

pip install structum-bootstrap

📚 Full Documentation

Documentation, API Reference, and Guides: 👉 https://structum.pages.dev/plugins/bootstrap

✨ Key Features

  • Fail Fast: Halts startup if critical requirements are not met.

  • Modular Validators: Checks for Files, Directories, Network Ports, URLs, and Env Vars.

  • Extensible: Simple API to create custom validators.

Bootstrap Plugin Package

Structum Bootstrap Plugin. Provides enterprise-grade validation and system checks.

class structum_lab.plugins.bootstrap.SystemBootstrapper[source]

Bases: object

Orchestrates the system validation process.

__init__()[source]

Initialize the bootstrapper with an empty validator list.

add_validator(validator: Validator) SystemBootstrapper[source]

Add a validator to the bootstrap sequence.

Parameters:
validator: Validator

A validator instance implementing the Validator protocol.

Returns:

Self for method chaining.

run() BootstrapContextImpl[source]

Run all validators and return the context.

run_or_exit() None[source]

Run validators and exit process if any fail.

structum_lab.plugins.bootstrap.BootstrapContext

alias of BootstrapContextImpl

class structum_lab.plugins.bootstrap.PythonVersionValidator(min_version: tuple[Any, ...] = (3, 9))[source]

Bases: object

Validates Python version.

__init__(min_version: tuple[Any, ...] = (3, 9))[source]

Initialize the validator.

Parameters:
min_version: tuple[Any, ...] = (3, 9)

Minimum required Python version tuple.

validate(context: ValidationContext) None[source]

Validate Python version meets minimum requirement.

class structum_lab.plugins.bootstrap.EnvVarValidator(required: list[str])[source]

Bases: object

Validates presence of environment variables.

__init__(required: list[str])[source]

Initialize the validator.

Parameters:
required: list[str]

List of required environment variable names.

validate(context: ValidationContext) None[source]

Validate that all required environment variables are set.

class structum_lab.plugins.bootstrap.DirectoryValidator(paths: list[str])[source]

Bases: object

Validates critical directories exist and are writable.

__init__(paths: list[str])[source]

Initialize the validator.

Parameters:
paths: list[str]

List of directory paths to validate.

validate(context: ValidationContext) None[source]

Validate that directories exist and are writable.

class structum_lab.plugins.bootstrap.ConfigValidator[source]

Bases: object

Validates that Structum configuration loads correctly.

validate(context: ValidationContext) None[source]

Validate that Structum configuration loads correctly.

Parameters:
context: ValidationContext

Validation context for recording results.

Core Bootstrap

Core implementation of the bootstrap validation context.

This module provides the concrete implementation of the ValidationContext protocol, used to collect and report validation results during bootstrap.

class structum_lab.plugins.bootstrap.core.BootstrapContextImpl[source]

Bases: object

Implementation of ValidationContext.

__init__()[source]

Initialize an empty validation context.

add_check(name: str, passed: bool, message: str = '') None[source]

Record a validation check result.

add_warning(message: str) None[source]

Add a non-fatal warning.

is_valid() bool[source]

Check if all validations passed.

Bootstrap Manager

System bootstrapper orchestration.

This module provides the SystemBootstrapper class, which orchestrates the execution of multiple validators during application startup.

class structum_lab.plugins.bootstrap.manager.SystemBootstrapper[source]

Bases: object

Orchestrates the system validation process.

__init__()[source]

Initialize the bootstrapper with an empty validator list.

add_validator(validator: Validator) SystemBootstrapper[source]

Add a validator to the bootstrap sequence.

Parameters:
validator: Validator

A validator instance implementing the Validator protocol.

Returns:

Self for method chaining.

run() BootstrapContextImpl[source]

Run all validators and return the context.

run_or_exit() None[source]

Run validators and exit process if any fail.

Validators

Built-in validators for system bootstrap.

This module provides common validation checks that can be used during application startup to ensure the runtime environment is correctly configured.

Example

>>> from structum_lab.plugins.bootstrap import SystemBootstrapper
>>> from structum_lab.plugins.bootstrap.validators import PythonVersionValidator
>>>
>>> boot = SystemBootstrapper()
>>> boot.add_validator(PythonVersionValidator(min_version=(3, 11)))
>>> boot.run_or_exit()
class structum_lab.plugins.bootstrap.validators.PythonVersionValidator(min_version: tuple[Any, ...] = (3, 9))[source]

Bases: object

Validates Python version.

__init__(min_version: tuple[Any, ...] = (3, 9))[source]

Initialize the validator.

Parameters:
min_version: tuple[Any, ...] = (3, 9)

Minimum required Python version tuple.

validate(context: ValidationContext) None[source]

Validate Python version meets minimum requirement.

class structum_lab.plugins.bootstrap.validators.EnvVarValidator(required: list[str])[source]

Bases: object

Validates presence of environment variables.

__init__(required: list[str])[source]

Initialize the validator.

Parameters:
required: list[str]

List of required environment variable names.

validate(context: ValidationContext) None[source]

Validate that all required environment variables are set.

class structum_lab.plugins.bootstrap.validators.DirectoryValidator(paths: list[str])[source]

Bases: object

Validates critical directories exist and are writable.

__init__(paths: list[str])[source]

Initialize the validator.

Parameters:
paths: list[str]

List of directory paths to validate.

validate(context: ValidationContext) None[source]

Validate that directories exist and are writable.

class structum_lab.plugins.bootstrap.validators.ConfigValidator[source]

Bases: object

Validates that Structum configuration loads correctly.

validate(context: ValidationContext) None[source]

Validate that Structum configuration loads correctly.

Parameters:
context: ValidationContext

Validation context for recording results.