manul

package module
v0.0.0-...-8850b9b Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2025 License: MIT Imports: 0 Imported by: 0

README

Cat Photos gRPC Service

A simple gRPC service for managing cat photos.

Build

Regenerate protobuf

protoc --go_out=paths=source_relative:.  --go-grpc_out=paths=source_relative:. cat_photos.proto
go mod download

Run Server

cd server
go run . -host=localhost -port=8081

Run Client

cd client

# List all cats
go run . -list-cats

# List photos for cat ID 1
go run . -list-photos=1

# Get photo and save to file
go run . -cat-id=1 -photo-id=1 -output=photo.dat

API

  • ListCats() - returns all cat IDs
  • ListPhotos(cat_id) - returns photo IDs for a cat
  • GetPhoto(cat_id, photo_id) - returns photo binary data

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBReader

type DBReader interface {
	// GetAllCatIDs returns all unique cat IDs in the database
	GetAllCatIDs() ([]uint64, error)

	// GetPhotoIDs returns all photo IDs for a specific cat
	GetPhotoIDs(catID uint64) ([]uint64, error)

	// GetPhotoData retrieves photo binary data by cat ID and photo ID
	GetPhotoData(catID, photoID uint64) ([]byte, error)

	// Close closes the database and releases resources
	Close() error
}

DBReader provides an abstract interface for reading cat photo databases. Different implementations can read data from different formats (file tree vs single bbolt file).

type DBWriter

type DBWriter interface {
	// AddPhoto adds a single photo to the database
	AddPhoto(catID, photoID uint64, photoData []byte) error

	// AddPhotosBatch adds multiple photos in a single transaction for better performance
	AddPhotosBatch(photos []PhotoItem) error

	// Close closes the database and releases resources
	Close() error
}

DBWriter provides an abstract interface for writing cat photo databases. Different implementations can store data in different formats (file tree vs single bbolt file).

type PhotoItem

type PhotoItem struct {
	CatID     uint64
	PhotoID   uint64
	FilePath  string
	PhotoData []byte
}

PhotoItem represents a photo with its metadata and binary data

Jump to

Keyboard shortcuts

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