todoapp

package
v0.0.0-...-2cbf6af Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

README

A ToDo App

ToDoApp, a backend microservice to get familiar with workspace

Documentation

Index

Constants

View Source
const (
	// ErrToDoItemNotFound when todo item is not found.
	ErrToDoItemNotFound = Error("todo item not found")
	// ErrToDoItemAlreadyExist when todo item already exist in the system.
	ErrToDoItemAlreadyExist = Error("todo item already exists")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error string

Error represents a Sampleapp error.

func (Error) Error

func (e Error) Error() string

Error returns the error message.

type ToDoItem

type ToDoItem struct {
	Id      string
	Title   string
	Details string
}

type ToDoService

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

ToDoService represent the service that manage todo without implementation detail, this aim to provide API that will be exposed to the handler (HTTP, GRPC)

func New

func New(storage ToDoStorage) *ToDoService

New create a new ToDoItem service.

func (*ToDoService) Create

func (u *ToDoService) Create(ctx context.Context, usr *ToDoItem) error

Create creates a new todo. If the todo already exist in the storage, ErrToDoItemAlreadyExist will be returned.

func (*ToDoService) Delete

func (u *ToDoService) Delete(ctx context.Context, id string) error

Delete deletes the todo form the todo storage.

func (*ToDoService) List

func (u *ToDoService) List(ctx context.Context) ([]ToDoItem, error)

List lists todos.

func (*ToDoService) Update

func (u *ToDoService) Update(ctx context.Context, updatedUsr *ToDoItem, mask_paths []string) error

Delete deletes the todo form the todo storage. If the todo does not exist, ErrToDoItemNotFound will be returned.

type ToDoStorage

type ToDoStorage interface {
	Fetch(ctx context.Context, id string) (*ToDoItem, error)
	List(ctx context.Context) ([]ToDoItem, error)
	Create(ctx context.Context, item *ToDoItem) error
	Update(ctx context.Context, item *ToDoItem) error
	Delete(ctx context.Context, id string) error
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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