customer

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: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeHandler

func MakeHandler(endpoints CustomerEndpoints, logger kitlog.Logger, ot stdopentracing.Tracer) http.Handler

Types

type Customer

type Customer struct {
	model.Base
	Name    string `pg:",notnull"`
	Address string `pg:",notnull"`
}

Customer represents the customer model

func NewCustomer

func NewCustomer(name, address string) (*Customer, error)

NewCustomer init a new customer with name and address.

type CustomerEndpoints

type CustomerEndpoints struct {
	RegisterEndpoint endpoint.Endpoint
	RentEndpoint     endpoint.Endpoint
}

func NewCustomerEndpoint

func NewCustomerEndpoint(cs Service, ot stdopentracing.Tracer) CustomerEndpoints

NewCustomerEndpoint wraps all customer service with all middlewares

type Middleware

type Middleware func(Service) Service

func NewInstrumentService

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

func NewLoggingService

func NewLoggingService(logger log.Logger) Middleware

NewLoggingService init a logging service

type ProxyMiddleware

type ProxyMiddleware func(ProxyService) ProxyService

func NewProxyMiddleware

func NewProxyMiddleware(conn *grpc.ClientConn, ctx context.Context, ot stdopentracing.Tracer, logger log.Logger) ProxyMiddleware

type ProxyService

type ProxyService interface {
	UpdateDVDStatus(ctx context.Context, DVDID string) error
}

type Repository

type Repository interface {
	Store(c *Customer) error
	GetByID(q string) (*Customer, error)
	Update(c *Customer) error
	Delete(c *Customer) error
}

Repository represent database/cache business

type Service

type Service interface {
	//Register customer
	Register(ctx context.Context, name, address string) error
	// Customer rent a dvd
	Rent(ctx context.Context, customerID, dvdID string) error
}

Service describe customer business

func NewCustomerService

func NewCustomerService(customerRepo Repository, dvdSvc ProxyService) Service

NewCustomerService init customer's service interface

func NewService

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

NewService return customerService with all expected function

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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