warehouse

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrepareStockAddedEvent

func PrepareStockAddedEvent(productId string, amount int32, reservationId *string) ([]byte, string, error)

func PrepareStockCreatedEvent

func PrepareStockCreatedEvent(productStock *pb.ProductStock) ([]byte, string, error)

func PrepareStockRemovedEvent

func PrepareStockRemovedEvent(productId string, amount int32, reservationId *string) ([]byte, string, error)

func PrepareStockReservationEvent_Consumed

func PrepareStockReservationEvent_Consumed(orderId string, reservationId string, reservedStock []*pb.ReservationStock) ([]byte, string, error)

func PrepareStockReservationEvent_Failed

func PrepareStockReservationEvent_Failed(orderId string, orderMetadata EventOrderMetadata, insufficientStockProductIds []string) ([]byte, string, error)

func PrepareStockReservationEvent_Reserved

func PrepareStockReservationEvent_Reserved(orderId string, orderMetadata EventOrderMetadata, reservationId string, reservationStock map[string]int32) ([]byte, string, error)

func PrepareStockReservationEvent_Returned

func PrepareStockReservationEvent_Returned(orderId string, reservationId string, reservedStock []*pb.ReservationStock) ([]byte, string, error)

Types

type ConsumerController

type ConsumerController interface {
	messaging.ConsumerController

	Attach(svc pb.WarehouseServiceServer)
}

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

type EventOrderMetadata

type EventOrderMetadata struct {
	CustomerId string
	ItemsPrice float32
	TotalPrice float32
}

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 {
	GetProductStock(ctx context.Context, productId string) (*pb.ProductStock, error)
	GetReservation(ctx context.Context, reservationId string) (*pb.Reservation, error)

	CreateProductStock(ctx context.Context, productId string, startingQuantity int32) error

	ReserveOrderStock(ctx context.Context, orderId string, orderMetadata EventOrderMetadata, productQuantities map[string]int32) error
	ReturnReservedOrderStock(ctx context.Context, orderId string) error
	ConsumeReservedOrderStock(ctx context.Context, orderId string) error
}

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

type WarehouseService

type WarehouseService struct {
	pb.UnimplementedWarehouseServiceServer
	// contains filtered or unexported fields
}

Interface for the service

func NewWarehouseService

func NewWarehouseService(cfg *ServiceConfig, store StorageController) *WarehouseService

Create the shipping service

func (WarehouseService) ProcessOrderPendingEvent

func (svc WarehouseService) ProcessOrderPendingEvent(ctx context.Context, req *eventpb.OrderPendingEvent) (*emptypb.Empty, error)

func (WarehouseService) ProcessPaymentProcessedEvent

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

func (WarehouseService) ProcessProductCreatedEvent

func (svc WarehouseService) ProcessProductCreatedEvent(ctx context.Context, req *eventpb.ProductCreatedEvent) (*emptypb.Empty, error)

func (WarehouseService) ProcessShipmentAllocationEvent

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

func (WarehouseService) ServiceInfo

func (WarehouseService) ViewProductStock

func (WarehouseService) ViewReservation

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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