Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is returned when the no records where matched by the query ErrNotFound = errors.New("not found") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config interface { // Logger returns a reference to the logger Logger() logging.Logger // DataDSN returns the data source name DataDSN() string }
Config is the configuration for the data package
type DAO ¶
type DAO struct { // Tracker is an optional query timer Tracker QueryTracker // contains filtered or unexported fields }
DAO is a data access object that provides an abstraction over our database interactions.
func NewDAO ¶
NewDAO will initialize the database connection pool (if not already done) and return a data access object which can be used to interact with the database
func (*DAO) Load ¶
Load will attempt to load and return a person. It will return ErrNotFound when the requested person does not exist. Any other errors returned are caused by the underlying database or our connection to it.
type LogTracker ¶
type LogTracker struct {
// contains filtered or unexported fields
}
LogTracker implements QueryTracker and outputs to the supplied logger
func NewLogTracker ¶
func NewLogTracker(logger logging.Logger) *LogTracker
NewLogTracker returns a Tracker that outputs tracking data to log
type Person ¶
type Person struct { // ID is the unique ID for this person ID int // FullName is the name of this person FullName string // Phone is the phone for this person Phone string // Currency is the currency this person has paid in Currency string // Price is the amount (in the above currency) paid by this person Price float64 }
Person is the data transfer object (DTO) for this package
type QueryTracker ¶
type QueryTracker interface { // Track will record/out the time a query took by calculating time.Now().Sub(start) Track(key string, start time.Time) }
QueryTracker is an interface to track query timing