mysql

package
v0.0.0-...-6d561a7 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package mysql provides the MySQL persistence target for Petclinic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

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

Database owns the Petclinic MySQL pool and migration lifecycle.

func OpenDatabase

func OpenDatabase(
	settings Settings,
) (*Database, lifecycle.Cleanup, error)

OpenDatabase constructs the MySQL pool without hidden environment reads or network I/O. Spice registers the returned cleanup immediately.

@Bean

func (*Database) Migrate

func (database *Database) Migrate(ctx context.Context) error

Migrate verifies connectivity and applies the locked, idempotent Petclinic schema before the application becomes ready.

MySQL DDL implicitly commits, so this profile is deliberately resumable rather than falsely claiming cross-statement transactional DDL.

@OnStart

type OwnerRepository

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

OwnerRepository persists complete owner aggregates in MySQL.

@Repository(constructor=NewOwnerRepository) @Implements(owner.Repository)

func NewOwnerRepository

func NewOwnerRepository(
	database *Database,
) (*OwnerRepository, error)

NewOwnerRepository constructs a MySQL owner repository.

func (*OwnerRepository) FindByID

func (repository *OwnerRepository) FindByID(
	ctx context.Context,
	id model.ID,
) (owner.Owner, bool, error)

FindByID returns one complete owner aggregate.

func (*OwnerRepository) FindByLastName

func (repository *OwnerRepository) FindByLastName(
	ctx context.Context,
	prefix string,
	offset int,
	limit int,
) ([]owner.Owner, int, error)

FindByLastName returns one bounded stable prefix page.

func (*OwnerRepository) Save

func (repository *OwnerRepository) Save(
	ctx context.Context,
	value owner.Owner,
) (saved owner.Owner, err error)

Save atomically inserts or updates one complete owner aggregate.

type PetTypeRepository

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

PetTypeRepository reads MySQL-backed pet type reference data.

@Repository(constructor=NewPetTypeRepository) @Implements(owner.PetTypeRepository)

func NewPetTypeRepository

func NewPetTypeRepository(
	database *Database,
) (*PetTypeRepository, error)

NewPetTypeRepository constructs a MySQL pet type repository.

func (*PetTypeRepository) FindAll

func (repository *PetTypeRepository) FindAll(
	ctx context.Context,
) (result []owner.PetType, err error)

FindAll returns pet types in stable display order.

type Settings

type Settings struct {
	URL           string `spice:"url,required,env=SPICE_PETCLINIC_MYSQL_URL,secret"`
	AllowInsecure bool   `spice:"allow-insecure,default=false,env=SPICE_PETCLINIC_MYSQL_ALLOW_INSECURE"`
}

Settings defines the explicit MySQL profile configuration.

@Configuration(prefix="petclinic.datasource")

type VetRepository

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

VetRepository reads MySQL-backed veterinarians.

@Repository(constructor=NewVetRepository) @Implements(vet.Repository)

func NewVetRepository

func NewVetRepository(database *Database) (*VetRepository, error)

NewVetRepository constructs a MySQL veterinarian repository.

func (*VetRepository) FindAll

func (repository *VetRepository) FindAll(
	ctx context.Context,
) ([]vet.Vet, error)

FindAll returns every veterinarian in stable display order.

func (*VetRepository) FindPage

func (repository *VetRepository) FindPage(
	ctx context.Context,
	offset int,
	limit int,
) ([]vet.Vet, int, error)

FindPage returns one bounded veterinarian page and total count.

Jump to

Keyboard shortcuts

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