Documentation ¶
Index ¶
- Constants
- Variables
- type Command
- type DB
- func (db *DB) Close() error
- func (db *DB) CommandStatus(uuid string) error
- func (db *DB) FinishCommand(uuid string, statusResult bool, reason string) error
- func (db *DB) NewPackage() (*Package, error)
- func (db *DB) Package(uuid string) (*Package, error)
- func (db *DB) Queue(name string) (*Queue, error)
- type ErrorStatus
- type Package
- type Queue
Constants ¶
const ( // BucketQueue is the outer bucket for other queue-oriented buckets, keyed by resource. BucketQueue = "queues" // BucketPackages is the outer bucket for all package queues. BucketPackages = "packages" // BucketCommands is the bucket for all commands. BucketCommands = "commands" // BucketStatuses is the bucket for all statuses. BucketStatuses = "statuses" )
Variables ¶
var ( // ErrRecordNotFound is returned when records are not found. This in // particular can happen in scenarios when requesting the status of an object // and it is unavailable. ErrRecordNotFound = errors.New("Record not found") // ErrRecordAlreadyExists is returned when trying to set a status that has // already been set. ErrRecordAlreadyExists = errors.New("Record already exists") )
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command struct { dispatcher.Command `json:",inline"` Parameters map[string]interface{} `json:"parameters"` }
Command is a unit of instruction; it contains a UUID, the unique identifier of the command, a Resource, the type of command to execute, an action, the name of the command to execute, and parameters, a collection of items that relate to the action for the purposes of execution.
Commands are typically fed to Packages, then the Package is Enqueued, Next() calls are made to yield the commands for the resource, the command is processed, FinishCommand is called to finish the command, then statuses are polled and eventually yielded.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is our DB handle. It contains a *bbolt.DB handle for internal use.
func New ¶
New creates a new database handle. The file is created if it does not already exist with 0600 perms, and some tuning is applied. The outermost buckets are also created at this time if they do not exist.
func (*DB) CommandStatus ¶
CommandStatus returns the status of the Command UUID as an error if faulty, otherwise nil for success.
func (*DB) FinishCommand ¶
FinishCommand reports a status for the Command UUID. If the result is true, reason is ignored.
func (*DB) NewPackage ¶
NewPackage creates a new Package and returns it, or error if there was any trouble. It will retry on collisions.
type ErrorStatus ¶
ErrorStatus is for status reports that are in an errored state. This includes the reason as well. The type mostly exists to distinguish it from other golang errors.
func (ErrorStatus) Error ¶
func (es ErrorStatus) Error() string
type Package ¶
type Package struct {
// contains filtered or unexported fields
}
Package is a collection of queue items that are in a waiting or enqueued state as a group.
func (*Package) Add ¶
Add adds a Command to the Package. It will be assigned a UUID which is written back to the pointered value. This may be retried. Any error writing to the database or marshaling the values will return an error.
func (*Package) Finished ¶
Finished returns non-nil if: - The package is unfinished (ErrRecordNotFound) - The package had errors (ErrorStatus)
Otherwise, it returns nil, which means everything ran fine.