order

package
v0.0.0-...-97f8d3b Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrepareOrderApprovedEvent

func PrepareOrderApprovedEvent(order *pb.Order) ([]byte, string, error)

func PrepareOrderCreatedEvent

func PrepareOrderCreatedEvent(order *pb.Order) ([]byte, string, error)

func PrepareOrderPendingEvent

func PrepareOrderPendingEvent(order *pb.Order) ([]byte, string, error)

func PrepareOrderRejectedEvent

func PrepareOrderRejectedEvent(order *pb.Order) ([]byte, string, error)

Types

type ConsumerController

type ConsumerController interface {
	messaging.ConsumerController

	Attach(svc pb.OrderServiceServer)
}

Interface for event consumption Flexibility for seperate controllers for different messaging systems (e.g. Kafka, NATS, etc)

type OrderService

type OrderService struct {
	pb.UnimplementedOrderServiceServer
	// contains filtered or unexported fields
}

Interface for the service

func NewOrderService

func NewOrderService(cfg *ServiceConfig, store StorageController) *OrderService

Create the order service

func (OrderService) PlaceOrder

func (OrderService) ProcessPaymentProcessedEvent

func (svc OrderService) ProcessPaymentProcessedEvent(ctx context.Context, req *eventpb.PaymentProcessedEvent) (*emptypb.Empty, error)

func (OrderService) ProcessProductPriceQuoteEvent

func (svc OrderService) ProcessProductPriceQuoteEvent(ctx context.Context, req *eventpb.ProductPriceQuoteEvent) (*emptypb.Empty, error)

func (OrderService) ProcessShipmentAllocationEvent

func (svc OrderService) ProcessShipmentAllocationEvent(ctx context.Context, req *eventpb.ShipmentAllocationEvent) (*emptypb.Empty, error)

func (OrderService) ProcessStockReservationEvent

func (svc OrderService) ProcessStockReservationEvent(ctx context.Context, req *eventpb.StockReservationEvent) (*emptypb.Empty, error)

func (OrderService) ServiceInfo

func (OrderService) ViewOrder

func (OrderService) ViewOrders

type ServiceConfig

type ServiceConfig struct {
	// Core Configuration
	Shared config.SharedConfig

	// Dynamically loaded configuration
	Postgres config.PostgresConfig
	Kafka    config.KafkaConfig
}

Order Service Configuration

func NewServiceConfig

func NewServiceConfig() (*ServiceConfig, error)

load the base service configuration

type StorageController

type StorageController interface {
	GetOrder(ctx context.Context, orderId string) (*pb.Order, error)
	GetCustomerOrders(ctx context.Context, customerId string) ([]*pb.Order, error)

	CreateOrder(ctx context.Context, order *pb.Order) (*pb.Order, error)
	ApproveOrder(ctx context.Context, orderId string, transactionId string) (*pb.Order, error)
	ProcessOrder(ctx context.Context, orderId string, itemsPrice float32) (*pb.Order, error)
	RejectOrder(ctx context.Context, orderId string) (*pb.Order, error)
	SetOrderShipmentId(ctx context.Context, orderId string, shippingId string) error
}

Interface for database methods Flexibility for implementing seperate controllers for different databases (e.g. Postgres, MongoDB, etc)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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