Documentation ¶
Index ¶
Constants ¶
const ( ErrNegativePuppyID = 400 ErrPuppyNotFound = 404 )
Error codes
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶
Error (our custom error type) wraps errors with code, message and error itself - what does this even mean??
type MapStore ¶
type MapStore struct {
// contains filtered or unexported fields
}
MapStore will serve as our in-memory DB
func NewMapStore ¶
func NewMapStore() *MapStore
NewSyncStore() conveniently creates a new initialised syncstore
func (*MapStore) CreatePuppy ¶
CreatePuppy lets you create a new unique puppy in MapStore
func (*MapStore) DeletePuppy ¶
DeletePuppy lets you delete a specific puppy in MapStore
type Storer ¶
type Storer interface { CreatePuppy(puppy *Puppy) (int, error) // takes a pointer which makes sense since you are modifying that object ReadPuppy(id int) (*Puppy, error) UpdatePuppy(id int, puppy *Puppy) error DeletePuppy(id int) error }
Storer defines standard CRUD operations for Pets
type SyncStore ¶
SyncStore struct. To serve as alternative in-memory DB. It also implements Storer interface
func NewSyncStore ¶
func NewSyncStore() *SyncStore
NewSyncStore() conveniently creates a new initialised syncstore
func (*SyncStore) CreatePuppy ¶
CreatePuppy creates a puppy in sync store. Note we use a pointer receiver for this
func (*SyncStore) DeletePuppy ¶
DeletePuppy deletes a puppy in sync store