orderapi

package
v0.0.0-...-3d84a2e Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: MIT-0 Imports: 14 Imported by: 2

Documentation

Overview

Package service contains the gRPC Order microservice implementation.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ProjectId is a variable so that unit tests can override it to ensures that test requests are not routed to
	// the live project! See https://firebase.google.com/doos/emulator-suite/connect_firestore
	ProjectId string

	// UnitTestNewOrderServiceError should be returned by NewOrderService if we are running unit tests
	// and unitTestNewOrderServiceError is not nil.
	UnitTestNewOrderServiceError error

	// PiiHash is the salt used by the PiiHashString function when rendering a PII string value into
	// a sufficiently unique string to be reliably searched for in logs without exposing the PII itself as
	// plain text.
	PiiHash hash.Hash
)

Functions

func PiiHashString

func PiiHashString(value string) string

PiiHashString renders a string PII value as a truncated base64 salted hash that can be safely rendered in logs to support searching without exposing PII values such as name and address as plain text.

Types

type OrderService

type OrderService struct {
	pborder.UnimplementedOrderAPIServer

	// FsClient is the GCP Firestore client - it is thread safe and can be reused concurrently
	FsClient *firestore.Client
	// contains filtered or unexported fields
}

OrderService is a structure class with methods that implements the order.OrderAPIServer gRPC API storing the data for orders in a Google Cloud Firestore document collection.

func NewOrderService

func NewOrderService() (*OrderService, error)

NewOrderService is a factory method returning an instance of our shopping cart service.

func (*OrderService) GetOrderByID

GetOrderByID retrieves an order matching the specified UUID ID in the pborder.GetOrderByIDRequest.

func (*OrderService) GetOrders

GetOrders retrieves a page of orders matching the search criteria specified UUID ID in the pborder.GetOrdersRequest.

func (*OrderService) SaveOrder

func (os *OrderService) SaveOrder(ctx context.Context, order *schema.Order) error

SaveOrder stores the given order in the Firestore document collection. This is for internal domain use only and so does not accept or return protobuf structures.

An error will be returned if the order is already present in Firestore. Orders are immutable!

Jump to

Keyboard shortcuts

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