Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UnwrapOpID ¶
UnwrapOpID extracts upload operation ID from a HMAC-protected string.
Types ¶
type Operation ¶
type Operation struct { ID int64 `gae:"$id"` Status api.UploadStatus Error string `gae:",noindex"` // error message if the verification failed TempGSPath string `gae:",noindex"` // the GS path to where the client uploads UploadURL string `gae:",noindex"` // resumable upload URL HashAlgo api.HashAlgo // the algo to use to verify the uploaded content HexDigest string // the expected content digest or "" if not known CreatedBy identity.Identity // who initiated the upload, FYI CreatedTS time.Time // when the upload was initiated, FYI UpdatedTS time.Time // last time this entity was saved, FYI // contains filtered or unexported fields }
Operation is a datastore entity that represents an upload.
func (*Operation) Advance ¶
func (op *Operation) Advance(c context.Context, cb func(context.Context, *Operation) error) (*Operation, error)
Advance transactionally updates the entity (by calling the callback) if its Status in the datastore is still same as op.Status.
If the entity in the datastore has different Status, silently skips calling the callback. It means the entity has been updated concurrently. This works because all Operation mutations actually switch statuses and the Operation state machine can "roll" only in one direction.
Returns the most recent state of the operation (whether it was mutated just now by the callback or not). 'op' itself is kept intact.
Returns only transient errors. All callback errors are tagged as transient as well.