Plugin Examples¶
This directory contains example plugins demonstrating various aspects of the Hop3 plugin system.
Available Examples¶
example-builder¶
A minimal build strategy plugin that demonstrates:
- Plugin structure and registration
- Builder protocol implementation
- Hook implementation (get_builders())
- Error handling and logging
- Build artifact creation
Use this example to learn:
- Basic plugin development workflow
- How to implement the accept() and build() methods
- How to return BuildArtifact information
- Best practices for build strategies
Using These Examples¶
As Learning Tools¶
- Read the code: Each example is heavily commented to explain key concepts
- Study the structure: Note how files are organized and named
- Check the README: Each example has a README explaining what it does
- Test locally: Try running the examples with test applications
As Templates¶
- Copy the example: Start with the example closest to your needs
- Rename files and classes: Update to match your plugin's purpose
- Modify the logic: Implement your specific functionality
- Test thoroughly: Ensure your plugin works with real applications
- Package it: Follow the External Plugin Guide
Example Structure¶
Each example follows this structure:
example-name/
├── README.md # What this example demonstrates
├── plugin.py # Plugin class with hook implementations
└── builder.py # Strategy implementation (builder, deployer, service, etc.)
For external plugins, you would add:
example-name/
├── pyproject.toml # Package metadata and entry points
├── LICENSE # License file (Apache 2.0 recommended)
├── src/
│ └── example_name/
│ ├── __init__.py
│ ├── plugin.py
│ └── builder.py
└── tests/
├── test_plugin.py
└── test_builder.py
Testing Examples¶
To test an example plugin:
# Navigate to example directory
cd example-builder
# Run Python to check imports
python3 -c "from plugin import plugin; print(plugin.name)"
# Test with hop3 (if installed)
python3 -c "from hop3.core.plugins import get_plugin_manager; pm = get_plugin_manager(); print([p.name for name, p in pm.list_name_plugin()])"
More Examples¶
Want to see more examples? Check:
- Real implementations in
packages/hop3-server/src/hop3/plugins/ postgresql/- Service strategy exampledocker/- Build and deployment strategiesproxy/nginx/- Proxy strategy example- Builder implementations in
packages/hop3-server/src/hop3/builders/ python.py- Production Python buildernode.py- Node.js builderstatic.py- Static file builder
Contributing Examples¶
Have a useful example to share? Contributions are welcome!
- Create your example following the structure above
- Document it thoroughly with comments and README
- Test it with real applications
- Submit a pull request
See Also¶
- Plugin Development Guide - Comprehensive plugin guide
- Protocol Reference - Strategy protocol specifications
- Hook Specifications - Available hooks
- External Plugin Guide - Publishing plugins