Documentation ¶
Index ¶
- func PrepareBalanceClosedEvent(bal *pb.CustomerBalance) ([]byte, string, error)
- func PrepareBalanceCreatedEvent(bal *pb.CustomerBalance) ([]byte, string, error)
- func PrepareBalanceCreditedEvent(customerId string, amount float32, newBalance float32) ([]byte, string, error)
- func PrepareBalanceDebitedEvent(customerId string, amount float32, newBalance float32) ([]byte, string, error)
- func PreparePaymentProcessedEvent_Failure(orderId string, customerId string, amount float32) ([]byte, string, error)
- func PreparePaymentProcessedEvent_Success(transaction *pb.Transaction) ([]byte, string, error)
- func PrepareTransactionLoggedEvent(transaction *pb.Transaction) ([]byte, string, error)
- func PrepareTransactionReversedEvent(transaction *pb.Transaction) ([]byte, string, error)
- type ConsumerController
- type PaymentService
- func (svc PaymentService) ProcessShipmentAllocationEvent(ctx context.Context, req *eventpb.ShipmentAllocationEvent) (*emptypb.Empty, error)
- func (svc PaymentService) ProcessUserCreatedEvent(ctx context.Context, req *eventpb.UserCreatedEvent) (*emptypb.Empty, error)
- func (svc PaymentService) ProcessUserDeletedEvent(ctx context.Context, req *eventpb.UserDeletedEvent) (*emptypb.Empty, error)
- func (svc PaymentService) ServiceInfo(ctx context.Context, req *commonpb.ServiceInfoRequest) (*commonpb.ServiceInfoResponse, error)
- func (svc PaymentService) ViewBalance(ctx context.Context, req *pb.ViewBalanceRequest) (*pb.ViewBalanceResponse, error)
- func (svc PaymentService) ViewTransaction(ctx context.Context, req *pb.ViewTransactionRequest) (*pb.ViewTransactionResponse, error)
- type ServiceConfig
- type StorageController
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrepareBalanceClosedEvent ¶
func PrepareBalanceClosedEvent(bal *pb.CustomerBalance) ([]byte, string, error)
func PrepareBalanceCreatedEvent ¶
func PrepareBalanceCreatedEvent(bal *pb.CustomerBalance) ([]byte, string, error)
func PreparePaymentProcessedEvent_Success ¶
func PreparePaymentProcessedEvent_Success(transaction *pb.Transaction) ([]byte, string, error)
func PrepareTransactionLoggedEvent ¶
func PrepareTransactionLoggedEvent(transaction *pb.Transaction) ([]byte, string, error)
func PrepareTransactionReversedEvent ¶
func PrepareTransactionReversedEvent(transaction *pb.Transaction) ([]byte, string, error)
Types ¶
type ConsumerController ¶
type ConsumerController interface { messaging.ConsumerController Attach(svc pb.PaymentServiceServer) }
Interface for event consumption Flexibility for seperate controllers for different messaging systems (e.g. Kafka, NATS, etc)
type PaymentService ¶
type PaymentService struct { pb.UnimplementedPaymentServiceServer // contains filtered or unexported fields }
Interface for the service
func NewPaymentService ¶
func NewPaymentService(cfg *ServiceConfig, store StorageController) *PaymentService
Create the payment service
func (PaymentService) ProcessShipmentAllocationEvent ¶
func (svc PaymentService) ProcessShipmentAllocationEvent(ctx context.Context, req *eventpb.ShipmentAllocationEvent) (*emptypb.Empty, error)
func (PaymentService) ProcessUserCreatedEvent ¶
func (svc PaymentService) ProcessUserCreatedEvent(ctx context.Context, req *eventpb.UserCreatedEvent) (*emptypb.Empty, error)
func (PaymentService) ProcessUserDeletedEvent ¶
func (svc PaymentService) ProcessUserDeletedEvent(ctx context.Context, req *eventpb.UserDeletedEvent) (*emptypb.Empty, error)
func (PaymentService) ServiceInfo ¶
func (svc PaymentService) ServiceInfo(ctx context.Context, req *commonpb.ServiceInfoRequest) (*commonpb.ServiceInfoResponse, error)
func (PaymentService) ViewBalance ¶
func (svc PaymentService) ViewBalance(ctx context.Context, req *pb.ViewBalanceRequest) (*pb.ViewBalanceResponse, error)
func (PaymentService) ViewTransaction ¶
func (svc PaymentService) ViewTransaction(ctx context.Context, req *pb.ViewTransactionRequest) (*pb.ViewTransactionResponse, error)
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 { GetBalance(ctx context.Context, customerId string) (*pb.CustomerBalance, error) GetTransaction(ctx context.Context, transactionId string) (*pb.Transaction, error) CreateBalance(ctx context.Context, customerId string) error CreditBalance(ctx context.Context, customerId string, amount float32) error DebitBalance(ctx context.Context, customerId string, amount float32, orderId *string) (*pb.Transaction, error) CloseBalance(ctx context.Context, customerId string) error PaymentForOrder(ctx context.Context, orderId string, customerId string, amount float32) error }
Interface for database methods Flexibility for implementing seperate controllers for different databases (e.g. Postgres, MongoDB, etc)
Click to show internal directories.
Click to hide internal directories.