orders

package
v0.0.0-...-bbf7e2a Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGrpcServer

func NewGrpcServer(port string, os OrdersService) *grpc.Server

func NewSqlDb

func NewSqlDb(dburl string) (*sql.DB, error)

Types

type ConsumerService

type ConsumerService interface {
	Consume(events []string) error
}

func NewEventConsumer

func NewEventConsumer(ch *amqp.Channel, exchangeName string, ordersRepo OrdersRepository) ConsumerService

type DetailedOrder

type DetailedOrder struct {
	Id            uuid.UUID
	UserId        uuid.UUID
	TotalQuantity int
	TotalPrice    int
	CreatedAt     time.Time
	Products      []*DetailedOrderProduct
}

type DetailedOrderProduct

type DetailedOrderProduct struct {
	ProductId uuid.UUID
	Quantity  int
	Price     int
}

type EventProducer

type EventProducer interface {
	Produce(key string, data []byte)
}

func NewEventProducer

func NewEventProducer(exchange string, ch *amqp.Channel) EventProducer

type Order

type Order struct {
	Id            uuid.UUID
	UserId        uuid.UUID
	TotalQuantity int
	TotalPrice    int
	CreatedAt     time.Time
}

type OrdersRepository

type OrdersRepository interface {
	FetchOrder(id uuid.UUID) (*DetailedOrder, error)
	FetchAllOrders() ([]*Order, error)
	CreateOrder(id uuid.UUID, userId uuid.UUID, totalQuantity int, priceTotal int, products []*DetailedOrderProduct) error
}

func NewOrdersRepository

func NewOrdersRepository(db *sql.DB) OrdersRepository

type OrdersService

type OrdersService interface {
	GetOrder(id uuid.UUID) (*DetailedOrder, error)
	GetAllOrders() ([]*Order, error)
	PlaceOrder(req PlaceOrderRequest) (*uuid.UUID, error)
}

func NewOrdersService

func NewOrdersService(repo OrdersRepository, p EventProducer) OrdersService

type PlaceOrderRequest

type PlaceOrderRequest struct {
	UserId   uuid.UUID
	Products []*DetailedOrderProduct
}

Jump to

Keyboard shortcuts

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