repository

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package repository implements the repository pattern for data access.

Package repository implements the repository pattern for data access.

Index

Constants

This section is empty.

Variables

View Source
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) Create

func (r *ConfigRepository) Create(ctx context.Context, c *models.Config) error

Create inserts a new config into the database.

func (*ConfigRepository) Delete

func (r *ConfigRepository) Delete(ctx context.Context, id string) error

Delete removes a config from the database.

func (*ConfigRepository) GetByID

func (r *ConfigRepository) GetByID(ctx context.Context, id string) (*models.Config, error)

GetByID retrieves a config by its ID.

func (*ConfigRepository) GetByName

func (r *ConfigRepository) GetByName(ctx context.Context, name string) (*models.Config, error)

GetByName retrieves a config by its name.

func (*ConfigRepository) List

func (r *ConfigRepository) List(ctx context.Context, limit, offset int) ([]*models.Config, error)

List retrieves all configs with pagination.

func (*ConfigRepository) Update

func (r *ConfigRepository) Update(ctx context.Context, c *models.Config) error

Update updates an existing config.

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

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

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

Update updates an existing deployment.

func (*DeploymentRepository) WithTx

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) Create

Create inserts a new execution into the database.

func (*ExecutionRepository) Delete

func (r *ExecutionRepository) Delete(ctx context.Context, id string) error

Delete removes an execution from the database.

func (*ExecutionRepository) GetByID

GetByID retrieves an execution by its ID.

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) Update

Update updates an existing execution.

func (*ExecutionRepository) WithTx

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL