StormDB v2 is a complete redesign of the PostgreSQL performance testing framework with a modular, plugin-based architecture.
The v2 architecture is built around a core service that provides essential functionality to loadable plugins:
- Database Manager: Connection pooling, health monitoring, transaction support
- Storage Manager: Test run tracking, result storage, metadata management
- Plugin Manager: Dynamic plugin loading, validation, lifecycle management
- Scheduler Manager: Task scheduling, worker pools, background execution
- Configuration Manager: Multi-format config loading, validation, plugin-specific configs
- Logging Manager: Structured logging with JSON/text formats, plugin context
Plugins implement the Plugin interface and receive access to core services:
type Plugin interface {
Metadata() PluginMetadata
Initialize(ctx context.Context, core *CoreServices) error
Validate(config map[string]interface{}) error
Execute(ctx context.Context, config map[string]interface{}) error
Cleanup(ctx context.Context) error
}- Go 1.21+
- PostgreSQL 12+
- Make (optional, for convenience commands)
# Install dependencies
make deps
# Build the application
make build
# Run in development mode
make devCreate config/core.yaml:
database:
host: "localhost"
port: 5432
database: "stormdb"
username: "postgres"
password: "your_password"
ssl_mode: "disable"
scheduler:
worker_pool_size: 10
plugin_dirs:
- "./plugins"# With default config
./build/stormdb
# With custom config
STORMDB_CONFIG=/path/to/config.yaml ./build/stormdbv2/
├── cmd/stormdb/ # Application entry point
├── core/ # Core service implementations
│ ├── config/ # Configuration management
│ ├── database/ # Database connection management
│ ├── logging/ # Structured logging
│ ├── plugin/ # Plugin loading and management
│ ├── scheduler/ # Task scheduling and execution
│ ├── storage/ # Test result storage
│ └── types.go # Core interfaces and types
├── migrations/ # Database schema migrations
├── config/ # Configuration files
├── plugins/ # Plugin implementations
└── examples/ # Example plugins and configs
The core schema includes:
test_type: Test type definitionsplugin: Plugin registry and metadatatest_metric: Metric definitions (latency, throughput, etc.)test_run: Test execution trackingtest_run_result: Individual measurement results
- Implement the
Plugininterface - Build as a shared library (
.sofile) - Place in a configured plugin directory
- Create plugin-specific configuration
package main
import (
"context"
"github.com/elchinoo/stormdb/v2/core"
)
type MyPlugin struct {
core *core.CoreServices
}
func (p *MyPlugin) Metadata() core.PluginMetadata {
return core.PluginMetadata{
Name: "my-plugin",
Version: "1.0.0",
Description: "Example plugin",
}
}
func (p *MyPlugin) Initialize(ctx context.Context, coreServices *core.CoreServices) error {
p.core = coreServices
return nil
}
// Implement other interface methods...
// Plugin entry point
func NewPlugin() core.Plugin {
return &MyPlugin{}
}- No hardcoded credentials in source code
- Plugin integrity verification with SHA256 checksums
- Secure configuration management
- Structured logging without sensitive data exposure
The v2 architecture is a complete rewrite and is not backward compatible with v1. The modular design allows for:
- Better separation of concerns
- Easier testing and maintenance
- Plugin-based extensibility
- Improved security posture
- Better performance monitoring
make test# Format code
make fmt
# Lint (requires golangci-lint)
make lint
# Security check (requires gosec)
make security- Follow the modular architecture principles
- Implement proper error handling and logging
- Add tests for new functionality
- Update documentation
[Include your license information here]