Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrBikeNotFound = errors.New("bike not found") ErrNotImplemented = errors.New("not implemented") )
Database based errors.
Functions ¶
Types ¶
type BikeStore ¶
type BikeStore interface { CreateBikes(ctx context.Context, bikes []Bike) ([]models.Bike, error) ListBikes(ctx context.Context, cursor string, limit int64) ([]models.Bike, error) FindBikeByPublicID(ctx context.Context, bikeID string) (*models.Bike, error) UpdateBikeLocation(ctx context.Context, bikeID string, lat, lng float64) error UnLockBikeByPublicID(ctx context.Context, bikeID string) (*models.Bike, error) LockBikeByPublicID(ctx context.Context, bikeID string) (*models.Bike, error) ListAllBikes(ctx context.Context, limit int64) ([]models.Bike, error) }
BikeStore specifies how bike service persisted its data.
func BikeStoreFromContext ¶
BikeStoreFromContext extracts a BikeStore from the Context.
type Location ¶
type Location struct { ID int64 Latitude float64 Longitude float64 TripID string CreatedAt time.Time }
Location is the database representation of a models.Location.
type Store ¶
Store specifies how persistance is handled in the app.
func NewPostgresDatabase ¶
func NewPostgresDatabase(ctx context.Context, config configuration.Database, logger logging.Logger) (Store, error)
NewPostgresDatabase return a valid Store with postgres.
type Trip ¶
type Trip struct { ID int64 PublicID string Status int BikeID string StartedAt time.Time EndedAt pq.NullTime }
Trip is the database representation of a models.Trip.
type TripStore ¶
type TripStore interface { GetLocationsForTrip(ctx context.Context, tripID string) ([]models.Location, error) AddLocationToTrip(ctx context.Context, tripID string, lat, lng float64) error CreateTrip(ctx context.Context, bikeID string, lat, lng float64) (*models.Trip, error) EndTrip(ctx context.Context, tripID string, lat, lng float64) (*models.Trip, error) }
TripStore specifies how trip service persisted its data.
func TripStoreFromContext ¶
TripStoreFromContext extracts a TripStore from the Context.
Click to show internal directories.
Click to hide internal directories.