shipping

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 PrepareShipmentAllocationEvent_Allocated

func PrepareShipmentAllocationEvent_Allocated(orderId string, orderMetadata EventOrderMetadata, shipmentId string, productQuantities map[string]int32) ([]byte, string, error)

func PrepareShipmentAllocationEvent_AllocationReleased

func PrepareShipmentAllocationEvent_AllocationReleased(orderId string, shipmentId string, shipmentItems []*pb.ShipmentItem) ([]byte, string, error)

func PrepareShipmentAllocationEvent_Failed

func PrepareShipmentAllocationEvent_Failed(orderId string, orderMetadata EventOrderMetadata, productQuantities map[string]int32) ([]byte, string, error)

func PrepareShipmentDispatchedEvent

func PrepareShipmentDispatchedEvent(orderId string, shipmentId string, productQuantities map[string]int32) ([]byte, string, error)

Types

type ConsumerController

type ConsumerController interface {
	messaging.ConsumerController

	Attach(svc pb.ShippingServiceServer)
}

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 ShippingService

type ShippingService struct {
	pb.UnimplementedShippingServiceServer
	// contains filtered or unexported fields
}

Interface for the service

func NewShippingService

func NewShippingService(cfg *ServiceConfig, store StorageController) *ShippingService

Create the shipping service

func (ShippingService) ProcessPaymentProcessedEvent

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

func (ShippingService) ProcessStockReservationEvent

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

func (ShippingService) ServiceInfo

func (ShippingService) ViewShipment

func (ShippingService) ViewShipmentManifest

type StorageController

type StorageController interface {
	GetShipment(ctx context.Context, shipmentId string) (*pb.Shipment, error)
	GetShipmentItems(ctx context.Context, shipmentId string) ([]*pb.ShipmentItem, error)

	AllocateOrderShipment(ctx context.Context, orderId string, orderMetadata EventOrderMetadata, productQuantities map[string]int32) error
	CancelOrderShipment(ctx context.Context, orderId 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