repository

package
v0.0.0-...-fc500c8 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// based the os package error names:
	// https://pkg.go.dev/os#pkg-variables
	ErrExist    = errors.New("repository: already exists")
	ErrNotExist = errors.New("repository: does not exist")

	// storage errors
	ErrRetry    = errors.New("repository: retry storage operation")
	ErrConflict = errors.New("repository: conflict in storage operation")
)

TODO: add metadata to errors to make em more useful:

  • what already exists
  • what was missing
  • what column(s) caused the conflict

Functions

This section is empty.

Types

type Itinerary

type Itinerary struct {
	ID uuid.UUID `db:"id"`

	Pattern        string    `db:"pattern"`
	FromLocationID uuid.UUID `db:"from_location_id"`
	ToLocationID   uuid.UUID `db:"to_location_id"`

	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
}

type ItineraryRepository

type ItineraryRepository interface {
	Create(itinerary *domain.Itinerary) error
	List() ([]*domain.Itinerary, error)
	Read(id uuid.UUID) (*domain.Itinerary, error)
	Delete(itinerary *domain.Itinerary) error
}

type Location

type Location struct {
	ID uuid.UUID `db:"id"`

	Kind       domain.LocationKind `db:"kind"`
	Info       []byte              `db:"info"`
	PingStatus domain.PingStatus   `db:"ping_status"`

	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`

	UsedBy []uuid.UUID `db:"used_by"`
}

type LocationRepository

type LocationRepository interface {
	Create(location *domain.Location) error
	List() ([]*domain.Location, error)
	Read(id uuid.UUID) (*domain.Location, error)
	Update(location *domain.Location) error
	Delete(location *domain.Location) error
}

type PostgresItineraryRepository

type PostgresItineraryRepository struct {
	// contains filtered or unexported fields
}

func NewPostgresItineraryRepository

func NewPostgresItineraryRepository(conn database.Conn) *PostgresItineraryRepository

func (*PostgresItineraryRepository) Create

func (repo *PostgresItineraryRepository) Create(itinerary *domain.Itinerary) error

func (*PostgresItineraryRepository) Delete

func (repo *PostgresItineraryRepository) Delete(itinerary *domain.Itinerary) error

func (*PostgresItineraryRepository) List

func (*PostgresItineraryRepository) Read

type PostgresLocationRepository

type PostgresLocationRepository struct {
	// contains filtered or unexported fields
}

func NewPostgresLocationRepository

func NewPostgresLocationRepository(conn database.Conn, box *secret.Box) *PostgresLocationRepository

func (*PostgresLocationRepository) Create

func (repo *PostgresLocationRepository) Create(location *domain.Location) error

func (*PostgresLocationRepository) Delete

func (repo *PostgresLocationRepository) Delete(location *domain.Location) error

func (*PostgresLocationRepository) List

func (repo *PostgresLocationRepository) List() ([]*domain.Location, error)

func (*PostgresLocationRepository) Read

func (*PostgresLocationRepository) Update

func (repo *PostgresLocationRepository) Update(location *domain.Location) error

type PostgresTransferRepository

type PostgresTransferRepository struct {
	// contains filtered or unexported fields
}

func NewPostgresTransferRepository

func NewPostgresTransferRepository(conn database.Conn) *PostgresTransferRepository

func (*PostgresTransferRepository) Acquire

func (repo *PostgresTransferRepository) Acquire() (*domain.Transfer, error)

func (*PostgresTransferRepository) Create

func (repo *PostgresTransferRepository) Create(transfer *domain.Transfer) error

func (*PostgresTransferRepository) Delete

func (repo *PostgresTransferRepository) Delete(transfer *domain.Transfer) error

func (*PostgresTransferRepository) List

func (repo *PostgresTransferRepository) List() ([]*domain.Transfer, error)

func (*PostgresTransferRepository) Read

func (*PostgresTransferRepository) Update

func (repo *PostgresTransferRepository) Update(transfer *domain.Transfer) error

type Repository

type Repository struct {
	Location  LocationRepository
	Itinerary ItineraryRepository
	Transfer  TransferRepository
}

func NewPostgres

func NewPostgres(conn database.Conn, box *secret.Box) *Repository

type Transfer

type Transfer struct {
	ID uuid.UUID `db:"id"`

	ItineraryID uuid.UUID             `db:"itinerary_id"`
	Status      domain.TransferStatus `db:"status"`
	Progress    int                   `db:"progress"`
	Error       string                `db:"error"`

	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
}

type TransferRepository

type TransferRepository interface {
	Create(transfer *domain.Transfer) error
	List() ([]*domain.Transfer, error)
	Read(id uuid.UUID) (*domain.Transfer, error)
	Update(transfer *domain.Transfer) error
	Delete(transfer *domain.Transfer) error
	Acquire() (*domain.Transfer, error)
}

Jump to

Keyboard shortcuts

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