storage

package
v0.0.0-...-5861b17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BirthdayToTime

func BirthdayToTime(ctx context.Context, d *dpb.Date) (time.Time, error)

BirthdayToTime converts the *pb.Pet.Birthday field to a time.Time object.

func ValidatePet

func ValidatePet(ctx context.Context, p *pb.Pet, forUpdate bool) error

ValidatePet validates that *pb.Pet has valid fields.

Types

type Data

type Data interface {
	// AddPets adds pet entries into storage.
	AddPets(ctx context.Context, pets []*pb.Pet) error
	// UpdatePets updates pet entries in storage.
	UpdatePets(ctx context.Context, pets []*pb.Pet) error
	// DeletePets deletes pets in storage by their ID. Will not error
	// on IDs not found.
	DeletePets(ctx context.Context, ids []string) error
	// SearchPets searches storage for pet entries that match the
	// filter.
	SearchPets(ctx context.Context, filter *pb.SearchPetsReq) chan SearchItem
}

Data represents our data storage.

type SearchItem

type SearchItem struct {
	// Pet is the pet that matched the search filters.
	Pet *pb.Pet
	// Error indicates that there was an error. If set the channel
	// will close after this entry.
	Error error
}

SearchItem is an item returned by a search.

Directories

Path Synopsis
Package mem contains an in-memory storage implementation of storage.Data.
Package mem contains an in-memory storage implementation of storage.Data.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL