Documentation ¶
Overview ¶
Package service contains the gRPC Fulfillment microservice implementation.
Index ¶
- Variables
- type FulfillmentService
- func (fs *FulfillmentService) GetTaskByID(ctx context.Context, req *pbfulfillment.GetTaskByIDRequest) (*pbfulfillment.GetTaskByIDResponse, error)
- func (fs *FulfillmentService) GetTasks(ctx context.Context, req *pbfulfillment.GetTasksRequest) (*pbfulfillment.GetTasksResponse, error)
- func (fs *FulfillmentService) SaveTasks(ctx context.Context, tasks []*schema.Task) error
- func (fs *FulfillmentService) UpdateTaskStatus(ctx context.Context, req *pbfulfillment.UpdateTaskStatusRequest) (*pbfulfillment.UpdateTaskStatusResponse, error)
Constants ¶
This section is empty.
Variables ¶
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 // UnitTestNewFulfillmentServiceError should be returned by NewTaskService if we are running unit tests // and unitTestNewTaskServiceError is not nil. UnitTestNewFulfillmentServiceError error )
Functions ¶
This section is empty.
Types ¶
type FulfillmentService ¶
type FulfillmentService struct { pbfulfillment.UnimplementedFulfillmentAPIServer // FsClient is the GCP Firestore client - it is thread safe and can be reused concurrently FsClient *firestore.Client // contains filtered or unexported fields }
FulfillmentService is a structure class with methods that implements the fulfillment.FulfillmentAPIServer gRPC API storing the data for managing fulfillment orchestration in a Google Cloud Firestore document collection.
func NewFulfillmentService ¶
func NewFulfillmentService() (*FulfillmentService, error)
NewFulfillmentService is a factory method returning an instance of our shopping cart service.
func (*FulfillmentService) GetTaskByID ¶
func (fs *FulfillmentService) GetTaskByID(ctx context.Context, req *pbfulfillment.GetTaskByIDRequest) (*pbfulfillment.GetTaskByIDResponse, error)
GetTaskByID retrieves a task matching the specified UUID ID in the fulfillment.GetTaskByIDRequest.
func (*FulfillmentService) GetTasks ¶
func (fs *FulfillmentService) GetTasks(ctx context.Context, req *pbfulfillment.GetTasksRequest) (*pbfulfillment.GetTasksResponse, error)
GetTasks retrieves a page of tasks matching the search criteria specified UUID ID in the fulfillment.GetTasksRequest.
func (*FulfillmentService) SaveTasks ¶
SaveTasks stores the given slices of schema.Task structures in the Firestore document collection. This is for internal domain use only and so does not accept or return protobuf structures.
Note that the submission time for the task will be set / overriden by this method to match the time it was written to Firestore.
An error will be returned if the tasks are already present in Firestore.
func (*FulfillmentService) UpdateTaskStatus ¶
func (fs *FulfillmentService) UpdateTaskStatus(ctx context.Context, req *pbfulfillment.UpdateTaskStatusRequest) (*pbfulfillment.UpdateTaskStatusResponse, error)
UpdateTaskStatus allows the caller to modify just the status of the task and the associate reason code, i.e. giving a description of why the status was changed. The reason code is optional.