repository

package
v0.0.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BackendMemory   = "memory"
	BackendMysql    = "mysql"
	BackendPostgres = "postgres"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Backend string `yaml:"backend"`

	Memory   MemoryConfig   `yaml:"memory"`
	Mysql    MysqlConfig    `yaml:"mysql"`
	Postgres PostgresConfig `yaml:"postgres"`
}

Config RepoCfg Connections config Here are each of the database connections for application.

func (*Config) RegisterFlags

func (cfg *Config) RegisterFlags(fs *flag.FlagSet)

func (*Config) Validate

func (cfg *Config) Validate() error

Validate RepoCfg config.

type MemoryConfig

type MemoryConfig struct {
	Enabled bool `yaml:"enabled"`
}

func (*MemoryConfig) RegisterFlags

func (cfg *MemoryConfig) RegisterFlags(fs *flag.FlagSet)

func (*MemoryConfig) RegisterFlagsWithPrefix

func (cfg *MemoryConfig) RegisterFlagsWithPrefix(prefix string, fs *flag.FlagSet)

func (*MemoryConfig) Validate

func (cfg *MemoryConfig) Validate() error

type MemoryRepo

type MemoryRepo struct {
	librarypb.UnimplementedLibraryServiceServer

	// shelves are stored in a map keyed by shelf id
	// books are stored in a two level map, keyed first by shelf id and then by book id
	Shelves     map[int64]*librarypb.Shelf
	Books       map[int64]map[int64]*librarypb.Book
	LastShelfID int64 // the id of the last shelf that was added
	LastBookID  int64 // the id of the last book that was added
	// contains filtered or unexported fields
}

MemoryRepo fulfills the Repository interface All objects are managed in an in-memory non-persistent store.

MemoryRepo is used to implement LibraryServiceServer.

func NewMemoryRepo

func NewMemoryRepo(_ MemoryConfig) (*MemoryRepo, error)

NewMemoryRepo is a factory function to generate a new repository

func (*MemoryRepo) ListShelves

type MysqlConfig

type MysqlConfig struct {
	Enabled bool `yaml:"enabled"`

	URL      string         `yaml:"url"`
	Host     string         `yaml:"host"`
	User     string         `yaml:"user"`
	Password flagext.Secret `yaml:"password"`
	Schema   string         `yaml:"schema"`
}

func (*MysqlConfig) RegisterFlags

func (cfg *MysqlConfig) RegisterFlags(fs *flag.FlagSet)

func (*MysqlConfig) RegisterFlagsWithPrefix

func (cfg *MysqlConfig) RegisterFlagsWithPrefix(prefix string, fs *flag.FlagSet)

func (*MysqlConfig) Validate

func (cfg *MysqlConfig) Validate() error

type MysqlRepo

type MysqlRepo struct {
	// contains filtered or unexported fields
}

MysqlRepo is used to implement LibraryServiceServer.

func NewMysqlRepo

func NewMysqlRepo(cfg MysqlConfig) (*MysqlRepo, error)

NewMysqlRepo is a factory function to generate a new repository

func (*MysqlRepo) CreateBook

func (*MysqlRepo) CreateShelf

func (*MysqlRepo) DeleteBook

func (*MysqlRepo) DeleteShelf

func (*MysqlRepo) GetBook

func (*MysqlRepo) GetShelf

func (*MysqlRepo) ListBooks

func (*MysqlRepo) MergeShelves

func (*MysqlRepo) MoveBook

func (*MysqlRepo) UpdateBook

type PostgresConfig

type PostgresConfig struct {
	Enabled bool `yaml:"enabled"`

	URL      string         `yaml:"url"`
	Host     string         `yaml:"host"`
	User     string         `yaml:"user"`
	Password flagext.Secret `yaml:"password"`
	Schema   string         `yaml:"schema"`
}

func (*PostgresConfig) RegisterFlags

func (cfg *PostgresConfig) RegisterFlags(fs *flag.FlagSet)

func (*PostgresConfig) RegisterFlagsWithPrefix

func (cfg *PostgresConfig) RegisterFlagsWithPrefix(prefix string, fs *flag.FlagSet)

func (*PostgresConfig) Validate

func (cfg *PostgresConfig) Validate() error

type PostgresRepo

type PostgresRepo struct {
	// contains filtered or unexported fields
}

func NewPostgresRepo

func NewPostgresRepo(cfg PostgresConfig) (*PostgresRepo, error)

func (*PostgresRepo) CreateBook

func (*PostgresRepo) CreateShelf

func (*PostgresRepo) DeleteBook

func (*PostgresRepo) DeleteShelf

func (*PostgresRepo) GetBook

func (*PostgresRepo) GetShelf

func (*PostgresRepo) ListBooks

func (*PostgresRepo) MergeShelves

func (*PostgresRepo) MoveBook

func (*PostgresRepo) UpdateBook

type Repository

type Repository interface {
	librarypb.LibraryServiceServer
}

func NewRepository

func NewRepository(cfg Config) (Repository, error)

Jump to

Keyboard shortcuts

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