Documentation ¶
Overview ¶
Package carsrp is the adapter for the cars repository. It exposes the carsrp.Repo type in order to allow use cases to manage car instances.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Park ¶
func Park[Q postgres.Queryer]( ctx context.Context, q Q, carID uuid.UUID, mode model.ParkingMode, ) (*model.Car, error)
Park example operation parks the car with carID UUID without changing its current location. It returns the updated car model and possible errors. The parking mode is recorded too. This generic function allows a unified implementation to be used for both of the connection and transaction receiving methods.
func UnparkAndMove ¶
func UnparkAndMove[Q postgres.Queryer](ctx context.Context, q Q, carID uuid.UUID, c model.Coordinate) (*model.Car, error)
UnparkAndMove example operation unparks a car with carID UUID, and moves it to the c destination coordinate. Updated car model and possible errors are returned. This generic function allows a unified implementation to be used for both of the connection and transaction receiving methods.
Types ¶
type Repo ¶
type Repo struct { }
Repo represents the cars repository instance.
func New ¶
func New() *Repo
New instantiates a cars Repo struct. Although this New does not perform complex operations, and users may use &carsrp.Repo{} directly too, but this method improves the code readability as carsrp.New() makes the package to look alike a data type.
func (*Repo) Conn ¶
func (cars *Repo) Conn(c repo.Conn) repo.CarsConnQueryer
Conn takes a Conn interface instance, unwraps it as required, and returns a CarsConnQueryer interface which (with access to the implementation-dependent connection object) can run different permitted operations on cars. The connQueryer itself is not mentioned as the return value since it is not exported. Otherwise, the general rule is to take interfaces as arguments and return exported structs.
func (*Repo) Tx ¶
func (cars *Repo) Tx(tx repo.Tx) repo.CarsTxQueryer
Tx takes a Tx interface instance, unwraps it as required, and returns a CarsTxQueryer interface which (with access to the implementation-dependent transaction object) can run different permitted operations on cars. The txQueryer itself is not mentioned as the return value since it is not exported. Otherwise, the general rule is to take interfaces as arguments and return exported structs.