Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DeploymentService ¶
type DeploymentService struct {
// contains filtered or unexported fields
}
DeploymentService implements the Deployer interface. Thread-Safety: NOT safe for concurrent Deploy() calls on the same instance. Create separate instances for concurrent deployments.
func NewDeploymentService ¶
func NewDeploymentService( connectorFactory func(*pgmi.ConnectionConfig) (pgmi.Connector, error), approver pgmi.Approver, logger pgmi.Logger, sessionManager pgmi.SessionPreparer, fileScanner pgmi.FileScanner, dbManager pgmi.DatabaseManager, ) *DeploymentService
NewDeploymentService creates a new DeploymentService with all dependencies injected.
Panic vs. Error Boundary Rationale:
- Panics on nil dependencies: These are programmer errors that should fail loudly at application startup, not during request handling. Fail-fast at construction time prevents cryptic nil pointer dereferences deep in call stacks.
- Returns errors for runtime conditions: Configuration validation, connection failures, and file system errors are recoverable runtime conditions that should be handled by the caller, not panics.
This distinction ensures unrecoverable setup errors are caught immediately while allowing graceful error handling for recoverable operational conditions.
func (*DeploymentService) Deploy ¶
func (s *DeploymentService) Deploy(ctx context.Context, config pgmi.DeploymentConfig) error
Deploy executes a deployment using the provided configuration. This method orchestrates the deployment workflow by calling smaller, focused methods.
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
SessionManager handles session initialization shared between deployment and testing. Responsibility: Scan files, connect to database, prepare session (utility functions, files, parameters).
SessionManager is thread-safe for concurrent use as long as the injected dependencies (connectorFactory, fileScanner, fileLoader, logger) are also thread-safe.
func NewSessionManager ¶
func NewSessionManager( connectorFactory func(*pgmi.ConnectionConfig) (pgmi.Connector, error), fileScanner pgmi.FileScanner, fileLoader pgmi.FileLoader, logger pgmi.Logger, ) *SessionManager
NewSessionManager creates a new SessionManager with all dependencies injected.
Panics if any dependency is nil. This is intentional fail-fast behavior to prevent cryptic nil pointer dereferences later. Panics indicate programmer error (incorrect dependency injection setup).
func (*SessionManager) PrepareSession ¶
func (sm *SessionManager) PrepareSession( ctx context.Context, connConfig *pgmi.ConnectionConfig, sourcePath string, parameters map[string]string, compat string, verbose bool, ) (*pgmi.Session, error)
PrepareSession scans files, validates, connects to database, and initializes the deployment session.
Returns:
- Session object encapsulating pool, connection, and scan results
- Error if any step fails
The caller is responsible for:
- Closing the session: defer session.Close()
The Session object provides access to Pool(), Conn(), and ScanResult() and manages cleanup of all resources through a single Close() method.