Documentation
¶
Overview ¶
Package repository implements the repository pattern for data access.
Package repository implements the repository pattern for data access.
Index ¶
- Variables
- type ConfigRepo
- type ConfigRepository
- func (r *ConfigRepository) Create(ctx context.Context, c *models.Config) error
- func (r *ConfigRepository) Delete(ctx context.Context, id string) error
- func (r *ConfigRepository) GetByID(ctx context.Context, id string) (*models.Config, error)
- func (r *ConfigRepository) GetByName(ctx context.Context, name string) (*models.Config, error)
- func (r *ConfigRepository) List(ctx context.Context, limit, offset int) ([]*models.Config, error)
- func (r *ConfigRepository) Update(ctx context.Context, c *models.Config) error
- func (r *ConfigRepository) WithTx(tx *sql.Tx) *ConfigRepository
- type DeploymentRepo
- type DeploymentRepository
- func (r *DeploymentRepository) Create(ctx context.Context, d *models.Deployment) error
- func (r *DeploymentRepository) Delete(ctx context.Context, id string) error
- func (r *DeploymentRepository) GetByID(ctx context.Context, id string) (*models.Deployment, error)
- func (r *DeploymentRepository) GetByName(ctx context.Context, name string) (*models.Deployment, error)
- func (r *DeploymentRepository) List(ctx context.Context, limit, offset int) ([]*models.Deployment, error)
- func (r *DeploymentRepository) Update(ctx context.Context, d *models.Deployment) error
- func (r *DeploymentRepository) WithTx(tx *sql.Tx) *DeploymentRepository
- type ExecutionRepo
- type ExecutionRepository
- func (r *ExecutionRepository) Create(ctx context.Context, e *models.Execution) error
- func (r *ExecutionRepository) Delete(ctx context.Context, id string) error
- func (r *ExecutionRepository) GetByID(ctx context.Context, id string) (*models.Execution, error)
- func (r *ExecutionRepository) List(ctx context.Context, limit, offset int) ([]*models.Execution, error)
- func (r *ExecutionRepository) ListByDeployment(ctx context.Context, deploymentID string, limit, offset int) ([]*models.Execution, error)
- func (r *ExecutionRepository) Update(ctx context.Context, e *models.Execution) error
- func (r *ExecutionRepository) WithTx(tx *sql.Tx) *ExecutionRepository
- type Querier
- type Repositories
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("record not found")
ErrNotFound is returned when a record is not found.
Functions ¶
This section is empty.
Types ¶
type ConfigRepo ¶
type ConfigRepo interface {
// Create inserts a new config.
Create(ctx context.Context, c *models.Config) error
// GetByID retrieves a config by its ID.
GetByID(ctx context.Context, id string) (*models.Config, error)
// GetByName retrieves a config by its name.
GetByName(ctx context.Context, name string) (*models.Config, error)
// List retrieves all configs with pagination.
List(ctx context.Context, limit, offset int) ([]*models.Config, error)
// Update updates an existing config.
Update(ctx context.Context, c *models.Config) error
// Delete removes a config.
Delete(ctx context.Context, id string) error
}
ConfigRepo defines the interface for config persistence operations. Both PostgreSQL and MongoDB implementations satisfy this interface.
type ConfigRepository ¶
type ConfigRepository struct {
// contains filtered or unexported fields
}
ConfigRepository handles config persistence.
func NewConfigRepository ¶
func NewConfigRepository(db Querier) *ConfigRepository
NewConfigRepository creates a new ConfigRepository.
func (*ConfigRepository) Delete ¶
func (r *ConfigRepository) Delete(ctx context.Context, id string) error
Delete removes a config from the database.
func (*ConfigRepository) WithTx ¶
func (r *ConfigRepository) WithTx(tx *sql.Tx) *ConfigRepository
WithTx returns a new ConfigRepository using the given transaction.
type DeploymentRepo ¶
type DeploymentRepo interface {
// Create inserts a new deployment.
Create(ctx context.Context, d *models.Deployment) error
// GetByID retrieves a deployment by its ID.
GetByID(ctx context.Context, id string) (*models.Deployment, error)
// GetByName retrieves a deployment by its name.
GetByName(ctx context.Context, name string) (*models.Deployment, error)
// List retrieves all deployments with pagination.
List(ctx context.Context, limit, offset int) ([]*models.Deployment, error)
// Update updates an existing deployment.
Update(ctx context.Context, d *models.Deployment) error
// Delete removes a deployment.
Delete(ctx context.Context, id string) error
}
DeploymentRepo defines the interface for deployment persistence operations. Both PostgreSQL and MongoDB implementations satisfy this interface.
type DeploymentRepository ¶
type DeploymentRepository struct {
// contains filtered or unexported fields
}
DeploymentRepository handles deployment persistence.
func NewDeploymentRepository ¶
func NewDeploymentRepository(db Querier) *DeploymentRepository
NewDeploymentRepository creates a new DeploymentRepository.
func (*DeploymentRepository) Create ¶
func (r *DeploymentRepository) Create(ctx context.Context, d *models.Deployment) error
Create inserts a new deployment into the database.
func (*DeploymentRepository) Delete ¶
func (r *DeploymentRepository) Delete(ctx context.Context, id string) error
Delete removes a deployment from the database.
func (*DeploymentRepository) GetByID ¶
func (r *DeploymentRepository) GetByID(ctx context.Context, id string) (*models.Deployment, error)
GetByID retrieves a deployment by its ID.
func (*DeploymentRepository) GetByName ¶
func (r *DeploymentRepository) GetByName(ctx context.Context, name string) (*models.Deployment, error)
GetByName retrieves a deployment by its name.
func (*DeploymentRepository) List ¶
func (r *DeploymentRepository) List(ctx context.Context, limit, offset int) ([]*models.Deployment, error)
List retrieves all deployments with pagination.
func (*DeploymentRepository) Update ¶
func (r *DeploymentRepository) Update(ctx context.Context, d *models.Deployment) error
Update updates an existing deployment.
func (*DeploymentRepository) WithTx ¶
func (r *DeploymentRepository) WithTx(tx *sql.Tx) *DeploymentRepository
WithTx returns a new DeploymentRepository using the given transaction.
type ExecutionRepo ¶
type ExecutionRepo interface {
// Create inserts a new execution.
Create(ctx context.Context, e *models.Execution) error
// GetByID retrieves an execution by its ID.
GetByID(ctx context.Context, id string) (*models.Execution, error)
// List retrieves all executions with pagination.
List(ctx context.Context, limit, offset int) ([]*models.Execution, error)
// ListByDeployment retrieves executions for a specific deployment.
ListByDeployment(ctx context.Context, deploymentID string, limit, offset int) ([]*models.Execution, error)
// Update updates an existing execution.
Update(ctx context.Context, e *models.Execution) error
// Delete removes an execution.
Delete(ctx context.Context, id string) error
}
ExecutionRepo defines the interface for execution persistence operations. Both PostgreSQL and MongoDB implementations satisfy this interface.
type ExecutionRepository ¶
type ExecutionRepository struct {
// contains filtered or unexported fields
}
ExecutionRepository handles execution persistence.
func NewExecutionRepository ¶
func NewExecutionRepository(db Querier) *ExecutionRepository
NewExecutionRepository creates a new ExecutionRepository.
func (*ExecutionRepository) Delete ¶
func (r *ExecutionRepository) Delete(ctx context.Context, id string) error
Delete removes an execution from the database.
func (*ExecutionRepository) List ¶
func (r *ExecutionRepository) List(ctx context.Context, limit, offset int) ([]*models.Execution, error)
List retrieves all executions with pagination.
func (*ExecutionRepository) ListByDeployment ¶
func (r *ExecutionRepository) ListByDeployment(ctx context.Context, deploymentID string, limit, offset int) ([]*models.Execution, error)
ListByDeployment retrieves executions for a specific deployment.
func (*ExecutionRepository) WithTx ¶
func (r *ExecutionRepository) WithTx(tx *sql.Tx) *ExecutionRepository
WithTx returns a new ExecutionRepository using the given transaction.
type Querier ¶
type Querier interface {
ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
}
Querier is an interface that can execute queries. Both *sql.DB and *sql.Tx implement this interface.
type Repositories ¶
type Repositories struct {
Deployments DeploymentRepo
Configs ConfigRepo
Executions ExecutionRepo
}
Repositories holds all repository interfaces for dependency injection.
func NewRepositories ¶
func NewRepositories(deployments *DeploymentRepository, configs *ConfigRepository, executions *ExecutionRepository) *Repositories
NewRepositories creates a Repositories instance from PostgreSQL repositories.