product

package
v0.0.0-...-531b5da Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrepareProductCreatedEvent

func PrepareProductCreatedEvent(product *pb.Product) ([]byte, string, error)

func PrepareProductDeletedEvent

func PrepareProductDeletedEvent(product *pb.Product) ([]byte, string, error)

func PrepareProductPriceQuoteEvent_Avaliable

func PrepareProductPriceQuoteEvent_Avaliable(orderId string, productQuantities map[string]int32, productPrices map[string]float32, totalPrice float32) ([]byte, string, error)

func PrepareProductPriceQuoteEvent_Unavaliable

func PrepareProductPriceQuoteEvent_Unavaliable(orderId string) ([]byte, string, error)

func PrepareProductPriceUpdatedEvent

func PrepareProductPriceUpdatedEvent(product *pb.Product) ([]byte, string, error)

Types

type ConsumerController

type ConsumerController interface {
	messaging.ConsumerController

	Attach(svc pb.ProductServiceServer)
}

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

type ProductService

type ProductService struct {
	pb.UnimplementedProductServiceServer
	// contains filtered or unexported fields
}

Interface for the service

func NewProductService

func NewProductService(cfg *ServiceConfig, store StorageController) *ProductService

Create the product service

func (ProductService) ProcessOrderCreatedEvent

func (svc ProductService) ProcessOrderCreatedEvent(ctx context.Context, req *eventpb.OrderCreatedEvent) (*emptypb.Empty, error)

func (ProductService) ServiceInfo

func (ProductService) ViewProduct

func (ProductService) ViewProducts

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 {
	GetProduct(ctx context.Context, productId string) (*pb.Product, error)
	GetProducts(ctx context.Context) ([]*pb.Product, error)

	UpdateProductPrice(ctx context.Context, productId string, price float32) (*pb.Product, error)
	DeleteProduct(ctx context.Context, productId string) error

	PriceOrderProducts(ctx context.Context, orderId string, customerId string, productQuantities map[string]int32) 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