mirror of
https://github.com/matt-dunleavy/plugin-manager.git
synced 2025-10-05 03:56:51 +08:00

This commit introduces significant improvements and new features to the plugin manager: - Add plugin discovery system and remote repository support - Implement plugin update system with digital signature verification - Enhance plugin lifecycle hooks (PreLoad, PostLoad, PreUnload) - Improve dependency management with custom version comparison - Introduce lazy loading for optimized plugin performance - Implement comprehensive error handling and logging - Enhance concurrency safety with fine-grained locking - Add plugin statistics tracking - Remove external version comparison dependencies - Improve hot-reload functionality with graceful shutdown - Add SSH key support for remote repositories - Implement Redbean server integration for plugin repositories This update significantly improves the plugin manager's functionality, security, and performance, providing a more robust and flexible system for managing plugins in Go applications.
54 lines
1007 B
Go
54 lines
1007 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
pm "github.com/matt-dunleavy/plugin-manager"
|
|
)
|
|
|
|
type MathPlugin struct{}
|
|
|
|
func (p *MathPlugin) Metadata() pm.PluginMetadata {
|
|
return pm.PluginMetadata{
|
|
Name: "MathPlugin",
|
|
Version: "1.0.0",
|
|
Dependencies: map[string]string{},
|
|
}
|
|
}
|
|
|
|
func (p *MathPlugin) Init() error {
|
|
fmt.Println("MathPlugin initialized")
|
|
return nil
|
|
}
|
|
|
|
func (p *MathPlugin) Execute() error {
|
|
result := p.Add(5, 3)
|
|
fmt.Printf("MathPlugin: 5 + 3 = %d\n", result)
|
|
return nil
|
|
}
|
|
|
|
func (p *MathPlugin) Shutdown() error {
|
|
fmt.Println("MathPlugin shut down")
|
|
return nil
|
|
}
|
|
|
|
func (p *MathPlugin) PreLoad() error {
|
|
fmt.Println("MathPlugin pre-load")
|
|
return nil
|
|
}
|
|
|
|
func (p *MathPlugin) PostLoad() error {
|
|
fmt.Println("MathPlugin post-load")
|
|
return nil
|
|
}
|
|
|
|
func (p *MathPlugin) PreUnload() error {
|
|
fmt.Println("MathPlugin pre-unload")
|
|
return nil
|
|
}
|
|
|
|
func (p *MathPlugin) Add(a, b int) int {
|
|
return a + b
|
|
}
|
|
|
|
var Plugin MathPlugin |