todos

package
v0.0.0-...-48bc69a Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IDGenerator

type IDGenerator func() string

type MemoryStorage

type MemoryStorage map[string]*pb.Todo

func (MemoryStorage) Delete

func (m MemoryStorage) Delete(ctx context.Context, id string) error

func (MemoryStorage) DeleteAll

func (m MemoryStorage) DeleteAll(ctx context.Context) error

func (MemoryStorage) Read

func (m MemoryStorage) Read(ctx context.Context, id string) (*pb.Todo, error)

func (MemoryStorage) ReadAll

func (m MemoryStorage) ReadAll(ctx context.Context) ([]*pb.Todo, error)

func (MemoryStorage) Save

func (m MemoryStorage) Save(ctx context.Context, todo *pb.Todo) error

type Server

type Server struct {
	pb.UnimplementedTodosServer
	// contains filtered or unexported fields
}

func NewServer

func NewServer(storage Storage, logger *zap.Logger) *Server

func (*Server) CreateTodo

func (s *Server) CreateTodo(ctx context.Context, in *pb.CreateTodoRequest) (*pb.Todo, error)

func (*Server) DeleteAllTodos

func (s *Server) DeleteAllTodos(ctx context.Context, in *empty.Empty) (*empty.Empty, error)

func (*Server) DeleteTodo

func (s *Server) DeleteTodo(ctx context.Context, in *pb.DeleteTodoRequest) (*empty.Empty, error)

func (*Server) GetTodo

func (s *Server) GetTodo(ctx context.Context, in *pb.GetTodoRequest) (*pb.Todo, error)

func (*Server) ListTodos

func (s *Server) ListTodos(ctx context.Context, in *pb.ListTodosRequest) (*pb.ListTodosResponse, error)

func (*Server) UpdateTodo

func (s *Server) UpdateTodo(ctx context.Context, in *pb.UpdateTodoRequest) (*pb.Todo, error)

type Storage

type Storage interface {
	Read(context.Context, string) (*pb.Todo, error)
	ReadAll(context.Context) ([]*pb.Todo, error)
	Delete(context.Context, string) error
	DeleteAll(context.Context) error
	Save(context.Context, *pb.Todo) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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