Documentation ¶
Index ¶
- Constants
- Variables
- func ExitCodeForCategory(category interface{}) int
- func ExitCodeForError(err error) int
- type Error
- type ErrorCategory
- type Event
- type Event_Log
- type Event_Progress
- type Event_Result
- type LogLevel
- type MirrorFunc
- type Monitor
- type PackFunc
- type PlacementMode
- type ScanFunc
- type UnpackFunc
Constants ¶
const ( ErrUsage = ErrorCategory("rio-usage-error") // Indicates some piece of user input to a command was invalid and unrunnable. ErrWarehouseUnwritable = ErrorCategory("rio-warehouse-unwritable") // Indicates a warehouse failed to accept a write operation. The Warehouse is having a bad day. ("unauthorized" is a different error category.) ErrWareNotFound = ErrorCategory("rio-ware-not-found") // Ware 404 -- warehouse appeared online, but the requested ware isn't in it. ErrWareCorrupt = ErrorCategory("rio-ware-corrupt") // Incidates a ware retreival started, but during unpacking it was found to be malformed. ErrWareHashMismatch = ErrorCategory("rio-hash-mismatch") // Returned when fetching and unpacking a ware gets results in a different content hash than we requested. (This is distinct from ErrWareCorrupt because a full fileset *was* able to be unpacked; it's just not the one we asked for.) ErrCancelled = ErrorCategory("rio-cancelled") // The operation timed out or was cancelled ErrLocalCacheProblem = ErrorCategory("rio-local-cache-problem") // Indicates an error while either reading or writing to rio's local fileset caches. ErrAssemblyInvalid = ErrorCategory("rio-assembly-invalid") // Indicates an error in unpack or tree-unpack where the requested set of unpacks cannot assemble cleanly (e.g. a tree where a /file is a file and another unpack tries to seat something at /file/dir; this assembly is impossible). ErrPackInvalid = ErrorCategory("rio-pack-invalid") // Indicates a pack could not be performed, perhaps because you tried to pack a file using a format that must start with dirs, or because of permission errors or other misfortunes during the pack. ErrInoperablePath = ErrorCategory("rio-inoperable-path") // Indicates pack or unpack failed while reading or writing the target local filesystem path (permissions errors, etc, are likely causes). ErrFilterRejection = ErrorCategory("rio-filter-rejection") // Indicates filters rejected some part of a fileset, e.g. `rio pack tar /dev --filter dev=reject` will return this error. ErrRPCBreakdown = ErrorCategory("rio-rpc-breakdown") // Raised when running a remote rio process and the control channel is lost, the process fails to start, or unrecognized messages are received. )
Variables ¶
var Atlas = atlas.MustBuild( Event_AtlasEntry, Error_AtlasEntry, commonatlases.Time_AsUnixInt, api.WareID_AtlasEntry, )
var ErrorTable = []struct { ExitCode int RioError ErrorCategory }{ {ExitCode: 1, RioError: ErrUsage}, {ExitCode: 2, RioError: ""}, {ExitCode: 3, RioError: ErrWarehouseUnavailable}, {ExitCode: 4, RioError: ErrWarehouseUnwritable}, {ExitCode: 5, RioError: ErrWareNotFound}, {ExitCode: 6, RioError: ErrWareCorrupt}, {ExitCode: 7, RioError: ErrWareHashMismatch}, {ExitCode: 8, RioError: ErrCancelled}, {ExitCode: 9, RioError: ErrLocalCacheProblem}, {ExitCode: 10, RioError: ErrAssemblyInvalid}, {ExitCode: 11, RioError: ErrPackInvalid}, {ExitCode: 12, RioError: ErrInoperablePath}, {ExitCode: 13, RioError: ErrFilterRejection}, {ExitCode: 120, RioError: ErrRPCBreakdown}, }
var Error_AtlasEntry = atlas.BuildEntry(Error{}).StructMap().Autogenerate().Complete()
var Event_AtlasEntry = atlas.BuildEntry((*Event)(nil)).KeyedUnion(). Of(map[string]*atlas.AtlasEntry{ "log": Event_Log_AtlasEntry, "prog": Event_Progress_AtlasEntry, "result": Event_Result_AtlasEntry, })
var Event_Log_AtlasEntry = atlas.BuildEntry(Event_Log{}).StructMap().Autogenerate().Complete()
var Event_Progress_AtlasEntry = atlas.BuildEntry(Event_Progress{}).StructMap().Autogenerate().Complete()
var Event_Result_AtlasEntry = atlas.BuildEntry(Event_Result{}).StructMap().Autogenerate().Complete()
Functions ¶
func ExitCodeForCategory ¶
func ExitCodeForCategory(category interface{}) int
ExitCodeForCategory translates an errcat category into a numeric exit code.
func ExitCodeForError ¶
ExitCodeForError translates an error into a numeric exit code, looking up a code based on the errcat category of the error.
Types ¶
type Error ¶
type Error struct { Category_ ErrorCategory `json:"category" refmt:"category"` Message_ string `json:"message" refmt:"message"` Details_ map[string]string `json:"details,omitempty" refmt:"details,omitempty"` }
Error implements the errcat.Error interface, specifically using this package's ErrorCategory as the concrete category, and giving us a type to hang custom serialization on.
type ErrorCategory ¶
type ErrorCategory string
type Event ¶
type Event interface {
// contains filtered or unexported methods
}
A "union" type of all the kinds of event that may be generated in the course of any of the functions.
type Event_Log ¶
type Event_Log struct { Time time.Time `refmt:"t"` Level LogLevel `refmt:"lvl"` Msg string `refmt:"msg"` Detail [][2]string `refmt:"detail,omitempty"` }
Logs from rio code.
type Event_Progress ¶
Notifications about progress updates.
Imagine it being used to draw the following:
Frobnozing (145/290kb): [=====> ] 50%
The 'totalProg' and 'totalWork' ints are expected to be a percentage; when they equal, a "done" state should be up next. A value of 'totalProg' greater than 'totalWork' is nonsensical.
The 'phase' and 'desc' args are freetext; Typically, 'phase' will remain the same for many calls in a row, while 'desc' is used to communicate a more specific contextual info than the 'total*' ints and like the ints may likely change on each call.
type Event_Result ¶
type Event_Result struct { WareID api.WareID `refmt:",omitempty"` Error *Error `refmt:",omitempty"` }
Final results. (Also converted into returns.)
type LogLevel ¶
type LogLevel int8
const ( LogError LogLevel = 4 // Error log lines, if used, mean the program is on its way to exiting non-zero. If used more than once, all but the first are other serious failures to clean up gracefully. LogWarn LogLevel = 3 // Warning logs are for systems which have failed, but in acceptable ways; for example, a warehouse that's not online (but a fallback is, so overall we proceeded happily). LogInfo LogLevel = 2 // Info logs are statements about control flow; for example, which warehouses have been tried in what order. LogDebug LogLevel = 1 // Debug logs are off by default. They may get down to the resolution of called per-file in a transmat, for example. )
type MirrorFunc ¶
type Monitor ¶
type Monitor struct {
Chan chan<- Event
}
Monitor hold a channel which is used for event reporting. Logs will be sent to the channel if one is provided.
The same channel and monitor may be used for multiple runs. The channel is not closed when the job is done; any goroutine with blocking service to a channel used for a single job should return after recieving an Event_Result, as it will be the final event.
type PlacementMode ¶
type PlacementMode string
const ( // "none" mode instructs unpack not to place the files at all -- but it // still updates the fileset cache. So, you can use this to warm up the // cache. The target path argument to unpack will be ignored. Placement_None PlacementMode = "none" // "copy" mode -- the default -- instructs unpack to use the cache of // already unpacked filesets (unpacking there in case of cache miss), and // then place the files in their final location by a plain file copy. Placement_Copy PlacementMode = "copy" // "mount" mode instructs unpack to use the fileset cache (same as "copy"), // then place the files in their final location by using some sort of mount. // Whether "mount" means "bind", "aufs", "overlayfs", etc is left to // interpretation, but regardless it A) should be faster than "copy" and // B) since it's a mount, may be slightly harder to rmdir :) Placement_Mount PlacementMode = "mount" // "direct" mode instructs unpack to skip the cache and work directly in // the target path. (It will still fall back to copy mode if the requested // ware is already in the fileset cache, "direct" is the one mode that // will not *populate* the fileset cache if empty.) Placement_Direct PlacementMode = "direct" )
type ScanFunc ¶
type ScanFunc func( ctx context.Context, packType api.PackType, filters api.FilesetUnpackFilter, placementMode PlacementMode, addr api.WarehouseLocation, monitor Monitor, ) (api.WareID, error)
type UnpackFunc ¶
type UnpackFunc func( ctx context.Context, wareID api.WareID, path string, filters api.FilesetUnpackFilter, placementMode PlacementMode, fetchFrom []api.WarehouseLocation, monitor Monitor, ) (api.WareID, error)