Documentation ¶
Index ¶
- func PrepareStockAddedEvent(productId string, amount int32, reservationId *string) ([]byte, string, error)
- func PrepareStockCreatedEvent(productStock *pb.ProductStock) ([]byte, string, error)
- func PrepareStockRemovedEvent(productId string, amount int32, reservationId *string) ([]byte, string, error)
- func PrepareStockReservationEvent_Consumed(orderId string, reservationId string, reservedStock []*pb.ReservationStock) ([]byte, string, error)
- func PrepareStockReservationEvent_Failed(orderId string, orderMetadata EventOrderMetadata, ...) ([]byte, string, error)
- func PrepareStockReservationEvent_Reserved(orderId string, orderMetadata EventOrderMetadata, reservationId string, ...) ([]byte, string, error)
- func PrepareStockReservationEvent_Returned(orderId string, reservationId string, reservedStock []*pb.ReservationStock) ([]byte, string, error)
- type ConsumerController
- type EventOrderMetadata
- type ServiceConfig
- type StorageController
- type WarehouseService
- func (svc WarehouseService) ProcessOrderPendingEvent(ctx context.Context, req *eventpb.OrderPendingEvent) (*emptypb.Empty, error)
- func (svc WarehouseService) ProcessPaymentProcessedEvent(ctx context.Context, req *eventpb.PaymentProcessedEvent) (*emptypb.Empty, error)
- func (svc WarehouseService) ProcessProductCreatedEvent(ctx context.Context, req *eventpb.ProductCreatedEvent) (*emptypb.Empty, error)
- func (svc WarehouseService) ProcessShipmentAllocationEvent(ctx context.Context, req *eventpb.ShipmentAllocationEvent) (*emptypb.Empty, error)
- func (svc WarehouseService) ServiceInfo(ctx context.Context, req *commonpb.ServiceInfoRequest) (*commonpb.ServiceInfoResponse, error)
- func (svc WarehouseService) ViewProductStock(ctx context.Context, req *pb.ViewProductStockRequest) (*pb.ViewProductStockResponse, error)
- func (svc WarehouseService) ViewReservation(ctx context.Context, req *pb.ViewReservationRequest) (*pb.ViewReservationResponse, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrepareStockAddedEvent ¶
func PrepareStockCreatedEvent ¶
func PrepareStockCreatedEvent(productStock *pb.ProductStock) ([]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 ServiceConfig ¶
type ServiceConfig struct { config.SharedConfig // Dynamically loaded configuration Postgres config.PostgresConfig Kafka config.KafkaConfig }Shared
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 (svc WarehouseService) ServiceInfo(ctx context.Context, req *commonpb.ServiceInfoRequest) (*commonpb.ServiceInfoResponse, error)
func (WarehouseService) ViewProductStock ¶
func (svc WarehouseService) ViewProductStock(ctx context.Context, req *pb.ViewProductStockRequest) (*pb.ViewProductStockResponse, error)
func (WarehouseService) ViewReservation ¶
func (svc WarehouseService) ViewReservation(ctx context.Context, req *pb.ViewReservationRequest) (*pb.ViewReservationResponse, error)
Click to show internal directories.
Click to hide internal directories.