Documentation
¶
Index ¶
- Variables
- type Comment
- type Service
- func (s *Service) DeleteComment(ctx context.Context, id string) error
- func (s *Service) GetComment(ctx context.Context, id string) (Comment, error)
- func (s *Service) PostComment(ctx context.Context, cmt Comment) (Comment, error)
- func (s *Service) UpdateComment(ctx context.Context, ID string, updatedCmt Comment) (Comment, error)
- type Store
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrFetchingComment = errors.New("failed to fetch comment by id") ErrNotImplemented = errors.New("not implemented") )
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
Store Store
}
Service - is the struct on which all the logic will be built on top of
func NewService ¶
NewService - returns a pointer to a new service
func (*Service) DeleteComment ¶
func (*Service) GetComment ¶
func (*Service) PostComment ¶
type Store ¶
type Store interface {
GetComment(context.Context, string) (Comment, error)
PostComment(context.Context, Comment) (Comment, error)
DeleteComment(context.Context, string) error
UpdateComment(context.Context, string, Comment) (Comment, error)
}
Store - this interface defines all the methods that the service needs to operate. 1. The benefit of this structure is that the storage interface can reach out to postgress, kasandera, etc 2. the store can be mocked for unit testing
Click to show internal directories.
Click to hide internal directories.