dvd

package
v0.0.0-...-0de774d Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Available = iota + 1
	NotAvailable
)

Variables

View Source
var Statuss = []Status{
	Available,
	NotAvailable,
}

Functions

func NewGRPCServer

func NewGRPCServer(endpoints DVDEndpoints, ot stdopentracing.Tracer, logger log.Logger) pb.DVDRentalServer

Types

type CreateDVDRequest

type CreateDVDRequest struct {
	Name string `json:"name"`
}

type CreateDVDResponse

type CreateDVDResponse struct {
	Err error `json:"error,omitempty"`
}

type DVD

type DVD struct {
	model.Base
	Name   string `pg:",notnull"`
	Status Status
}

func NewDVD

func NewDVD(name string) (*DVD, error)

NewDVD generate a dvd model with input name

type DVDEndpoints

type DVDEndpoints struct {
	CreateDVDEndpoint endpoint.Endpoint
	RentDVDEndpoint   endpoint.Endpoint
}

func NewDVDEndpoint

func NewDVDEndpoint(svc Service, ot stdopentracing.Tracer) DVDEndpoints

func (DVDEndpoints) CreateDVD

func (ep DVDEndpoints) CreateDVD(ctx context.Context, name string) error

func (DVDEndpoints) RentDVD

func (ep DVDEndpoints) RentDVD(ctx context.Context, id string) error

type Middleware

type Middleware func(Service) Service

func NewLoggerMiddleware

func NewLoggerMiddleware(logger log.Logger) Middleware

func NewMetrictMiddleware

func NewMetrictMiddleware(counter metrics.Counter, histogram metrics.Histogram) Middleware

type RentDVDRequest

type RentDVDRequest struct {
	ID string `json:"id"`
}

type RentDVDResponse

type RentDVDResponse struct {
	Err error `json:"error,omitempty"`
}

type Repository

type Repository interface {
	Store(dvd *DVD) error
	Update(id string, status Status) error
}

type Service

type Service interface {
	CreateDVD(ctx context.Context, name string) error
	RentDVD(ctx context.Context, id string) error
}

func NewDVDService

func NewDVDService(dvdRepo Repository) Service

func NewService

func NewService(dvdRepo Repository, logger log.Logger, counter metrics.Counter, histogram metrics.Histogram) Service

type Status

type Status uint8

func (Status) ToString

func (s Status) ToString() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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