Documentation ¶
Index ¶
- Constants
- Variables
- func DeleteByID(svc ServiceI) endpoint.Endpoint
- func FindByID(svc ServiceI) endpoint.Endpoint
- func Upsert(svc ServiceI) endpoint.Endpoint
- type CountMetric
- type DeleteRequest
- type Execer
- type FindByIDRequest
- type JSONRequest
- type JSONResponse
- type Querier
- type Quote
- type RepositoryI
- type RepositoryMemory
- type Service
- type ServiceI
- type UpsertRequest
Constants ¶
View Source
const ( UpsertMetricName string = "upsert_total" UpsertHelp string = "total number of calls to upsert" )
Variables ¶
View Source
var ( // ErrNew represents an error when creating a new Quote ErrNew = errors.New("unable to create new quote") // ErrEmptyRepository repository cannot be nil ErrEmptyRepository = errors.New("empty repository") // ErrTypeAssertion arises while trying to perform interface{}.(T) ErrTypeAssertion = errors.New("unable to execute type assertion") )
View Source
var RESTErrorBussines = restError{ ErrNew: {"Sorry, we cannot create a new quote", http.StatusInternalServerError}, sql.ErrNoRows: {"Record not found", http.StatusNotFound}, }
RESTErrorBussines Errors you want to map to more meaning response for clients and set specific HTTP status code should be included here
Functions ¶
func DeleteByID ¶
Types ¶
type CountMetric ¶
type CountMetric struct {
// contains filtered or unexported fields
}
CountMetric is a domain level metric middleware using prometheus.
func NewCountMetric ¶
func NewCountMetric(quoteService ServiceI, counter prometheus.Counter) *CountMetric
type DeleteRequest ¶
type FindByIDRequest ¶
type JSONRequest ¶
type JSONResponse ¶
type RepositoryI ¶
type RepositoryI interface { // Queries is a "Readeble" interface responsible to read data from source Querier // Execer is a "Writable" interface responsible for write data into source Execer }
RepositoryI is a interface to communicate with a external source of data (ex: Postgres, Firebase FireStore or an API) It is using the concept of having a readable interface called "Querier" and a Writable interface called "Execer", which exec actions into the external source of data.
type RepositoryMemory ¶
type RepositoryMemory struct {
// contains filtered or unexported fields
}
func NewRepository ¶
func NewRepository(logger log.Logger) *RepositoryMemory
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(repository RepositoryI, log log.Logger) (*Service, error)
type UpsertRequest ¶
type UpsertRequest struct {
JSONRequest
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.