Documentation ¶
Overview ¶
Package tasktrigger handles Firestore trigger invocations when order documents are updated.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // TopicProjectId 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/docs/emulator-suite/connect_firestore TopicProjectId string // TopicId a variable so that unit tests can override it to force errors to occur TopicId string )
Functions ¶
func TaskTrigger ¶
func TaskTrigger(ctx context.Context, e FirestoreEvent) error
TaskTrigger receives a document update Firestore trigger event. The function is deployed with a trigger configuration (see Makefile) that will notify the handler of all updates to the root document of a Task.
Types ¶
type FirestoreEvent ¶
type FirestoreEvent struct { OldValue FirestoreValue `json:"oldValue"` Value FirestoreValue `json:"value"` UpdateMask struct { FieldPaths []string `json:"fieldPaths"` } `json:"updateMask"` }
FirestoreEvent is the payload of a Firestore event.
type FirestoreTask ¶
type FirestoreTask struct { Id StringValue `json:"id"` Status IntegerValue `json:"status"` }
FirestoreTask describes the document fields that we need to know about as they will be found in the event data (not as we would prefer them, in the structure that we submitted to the Firestore API to populate the document in the first place :-(
type FirestoreValue ¶
type FirestoreValue struct { CreateTime time.Time `json:"createTime"` Fields FirestoreTask `json:"fields"` Name string `json:"name"` UpdateTime time.Time `json:"updateTime"` }
FirestoreValue holds Firestore document fields.
type FulfillmentServiceClient ¶
type FulfillmentServiceClient interface {
GetTask(ctx context.Context, taskId string) (*pbfulfillment.Task, error)
}
FulfillmentServiceClient is a wrapper for the fulfillment service that supports lazy loading of the service and unit test error generation.
type FulfillmentServiceClientImpl ¶
type FulfillmentServiceClientImpl struct { FulfillmentServiceClient // contains filtered or unexported fields }
FulfillmentServiceClientImpl is the default implementation of the FulfillmentServiceClient interface. error generation.
func (*FulfillmentServiceClientImpl) GetTask ¶
func (c *FulfillmentServiceClientImpl) GetTask(ctx context.Context, taskId string) (*pbfulfillment.Task, error)
GetTask loads a fully populated task from Firestore.
type IntegerValue ¶
type IntegerValue struct {
IntegerValue string `json:"integerValue"`
}
type PubSubClient ¶
type PubSubClient interface {
Publish(ctx context.Context, order *pbfulfillment.Task) error
}
PubSubClient is a wrapper for our Google client that supports lazy loading of the client and unit test error generation.
type PubSubClientImpl ¶
type PubSubClientImpl struct { PubSubClient // contains filtered or unexported fields }
PubSubClientImpl is the default implementation of the PubSubClient interface.
func (*PubSubClientImpl) Publish ¶
func (c *PubSubClientImpl) Publish(ctx context.Context, task *pbfulfillment.Task) error
Publish submits a binary message to our configured Pub/Sub topic.
type StringValue ¶
type StringValue struct {
StringValue string `json:"stringValue"`
}