Documentation
¶
Overview ¶
Package workspace holds fetched files in the lockfile account: one private directory per handle, a random file name, never the source name. Nothing here is shown to the agent but the handle; Info is for the audit.
Index ¶
- Constants
- Variables
- type Config
- type Handle
- type Info
- type Manager
- func (m *Manager) Close() error
- func (m *Manager) Create(r io.Reader, max int64) (h Handle, info Info, err error)
- func (m *Manager) Dir() string
- func (m *Manager) Expire()
- func (m *Manager) OpenFile(h Handle) (*os.File, Info, error)
- func (m *Manager) Release(h Handle) error
- func (m *Manager) SetLimits(maxBytes int64, ttl time.Duration)
Constants ¶
const ( DefaultMaxBytes = 1 << 30 DefaultTTL = 30 * time.Minute DefaultMaxHandles = 64 )
Defaults for zero Config fields.
Variables ¶
var ( ErrTooLarge = errors.New("workspace: file too large") ErrExpired = errors.New("handle_expired") ErrUnknownHandle = errors.New("workspace: unknown handle") // ErrTooManyHandles refuses a fetch while MaxHandles files are held. ErrTooManyHandles = errors.New("workspace: too many handles") )
Functions ¶
This section is empty.
Types ¶
type Handle ¶
type Handle string
Handle names a fetched file for the agent: "f_" and 10 base62 characters from crypto/rand, unrelated to anything about the file.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func Open ¶
Open prepares the workspace root (0700) and removes everything a previous console left in it.
func (*Manager) Create ¶
Create streams r into a new handle, hashing as it copies. It fails with ErrTooLarge, and leaves nothing behind, as soon as the file exceeds max or the space left in the workspace, and with ErrTooManyHandles when MaxHandles files are already held or being fetched. The bytes it may write are reserved before streaming, so concurrent fetches never take more than the workspace budget together; what the file did not use is refunded.
func (*Manager) Expire ¶
func (m *Manager) Expire()
Expire deletes the files of every handle past its TTL. The handles keep answering ErrExpired.