Documentation ¶
Overview ¶
Package carsuc contains the cars UseCase which supports the cars related use cases. Currently, two uses cases are supported:
- Riding a car,
- Parking a car.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
Option is a functional option for the cars use case.
func WithOldParkingMethodDelay ¶
WithOldParkingMethodDelay option configures a cars UseCase instance in order to incur as much as the given delay during the old-method parking operations. This option may be passed to the New() function.
type UseCase ¶
type UseCase struct {
// contains filtered or unexported fields
}
UseCase represents a cars use case. It holds a database connection pool, the cars repository instance (to be guided with the DB pool), and the cars use case specific settings.
func New ¶
New instantiates a cars use case. Required parameters are passed individually, so caller has to provision them and whenever they change, caller will notice and fix them due to a compilation error. Optional parameters are passed as a series of functional options in order to facilitate their validation and flexibility.
func (*UseCase) Park ¶
func (cars *UseCase) Park(ctx context.Context, cid uuid.UUID, mode model.ParkingMode) (car *model.Car, err error)
Park use case tries to park the cid car using the mode parking mode. The new parking mode works quickly while the old method incurs delay based on the configuration. It returns the updated car model and possible errors.