Documentation
¶
Overview ¶
Package transaction contains higher level logic used for ingesting content. It is intended to support the server package. A transaction here is the same as a transaction from the viewpoint of the web UI. Transactions handle the details of storing and manipulating the item uploads for Bendo. Eventually these transactions are turned into a sequence of calls to an item.Writer object.
This package builds on the fragment package. A transaction is represented by a bunch of Files; one for the transaction metadata, and as many more as are needed to hold the blobs to be added to the given item.
There is not really a clear distinction between what belongs in here verses what belongs in the server. For now, all the goroutine code is in the server, and the status monitoring straddles the two. Probably the status code should be moved completely into one package or the other.
Index ¶
- Variables
- type Status
- type Store
- type Transaction
- func (tx *Transaction) AddCommandList(cmds [][]string) error
- func (tx *Transaction) AppendError(e string)
- func (tx *Transaction) Commit(s items.Store, files *fragment.Store, cache blobcache.T)
- func (tx *Transaction) ReferencedFiles() []string
- func (tx *Transaction) SetStatus(s Status)
- func (tx *Transaction) VerifyFiles(files *fragment.Store)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrExistingTransaction occurs when trying to start a transaction on // an item already having a pending transaction. ErrExistingTransaction = errors.New("existing transaction for that item") // ErrBadCommand means a bad command was passed to the ingest routine. ErrBadCommand = errors.New("Bad command") )
Functions ¶
This section is empty.
Types ¶
type Status ¶
type Status int
The Status of a transaction.
const ( StatusUnknown Status = iota // zero status value StatusOpen // transaction is being modified by user StatusWaiting // transaction has been submitted to be committed StatusChecking // files are being checksummed and verified StatusIngest // files are being written into bundles StatusFinished // transaction is over, successful StatusError // transaction had an error )
The possible status states for the processing of a transaction.
type Store ¶
A Store tracks item transactions.
func New ¶
New creates a new transaction store using the given a store to save all the associated items. Make sure to call Load() on the returned structure to reload the metadata from the underlying store.
func (*Store) Create ¶
func (r *Store) Create(itemid string) (*Transaction, error)
Create a new transaction to update itemid. There can be at most one transaction per itemid.
func (*Store) Lookup ¶
func (r *Store) Lookup(txid string) *Transaction
Lookup the given transaction identifier and return a pointer to the transaction. Returns nil if there is no transaction with that id.
type Transaction ¶
type Transaction struct { M sync.RWMutex // protects everything below ID string // the id of this transaction Status Status // one of Status* Started time.Time // time tx was created Modified time.Time // last time user touch or added a file Err []string // list of errors (for StatusError) Creator string // username of the committer ItemID string // ID of the item this tx is modifying Commands []command // commands to run on commit BlobMap map[string]int // tracks the blob id we used for uploaded files // contains filtered or unexported fields }
Transaction Represents a single transaction.
func (*Transaction) AddCommandList ¶
func (tx *Transaction) AddCommandList(cmds [][]string) error
AddCommandList changes the command list to process when committing this transaction to the one given.
func (*Transaction) AppendError ¶
func (tx *Transaction) AppendError(e string)
AppendError appends the given error string to this transaction. It will acquire the write lock on tx.
func (*Transaction) Commit ¶
Commit this transaction to the given store, creating or updating the underlying item. Commit a creation/update of an item in s, possibly using files in files, and with the given creator name.
func (*Transaction) ReferencedFiles ¶
func (tx *Transaction) ReferencedFiles() []string
ReferencedFiles returns a list of all the upload file ids associated with this transaction. That is, all the files referenced by an "add" command.
func (*Transaction) SetStatus ¶
func (tx *Transaction) SetStatus(s Status)
SetStatus updates the status of this transaction to s.
func (*Transaction) VerifyFiles ¶
func (tx *Transaction) VerifyFiles(files *fragment.Store)
VerifyFiles verifies the checksums of all the files being added by this transaction. Pass in the fragment store containing the uploaded files. Any negative results are returned in tx.Err.