payload

package
v0.7.58-dev.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package payload carries the files a run on a remote runhost takes from the device: its inputs, the files that answer its intake questions, the knowledge packs it attaches, its Writing Voice and its report design. The device packs them into one tar, which follows the job's document (and its release, when the runhost asks for it) and is laid down in the job's private directory on the server.

A member's name is one of the kinds below, then a name of its own: inputs/<name>…, intake/<id>/<name>…, knowledge/<pack>/…, voice/VOICE.md and design/report-design.json. Only regular files and directories travel.

Index

Constants

View Source
const (
	KindInputs    = "inputs"
	KindIntake    = "intake"
	KindKnowledge = "knowledge"
	KindVoice     = "voice"
	KindDesign    = "design"
)

The kinds of member, each the first segment of a member's name.

View Source
const MaxPayload = 4 << 30

MaxPayload bounds the files one run takes: the same as the most output a run gives back.

Variables

This section is empty.

Functions

func CleanName

func CleanName(name string) string

CleanName is name when it is a clean relative member name under one of the kinds, else "".

func Unpack

func Unpack(r io.Reader, size int64, digest, dir string) error

Unpack reads exactly size bytes of r, a tar Pack wrote whose digest is digest, into dir, which it creates owner-only: regular files and directories only, each under a clean member name, so no entry lands outside dir. The digest is checked once the stream ends; a payload that does not match leaves dir to its caller to remove.

Types

type Entry

type Entry struct {
	// Name is the member's slash-separated name: a kind, then its own.
	Name string
	// Src is the file or directory on the device. A link to a regular file
	// is read through, as a local run copies one; a link inside a directory
	// to a directory is not followed.
	Src string
}

Entry is one file or directory of the device's, packed under Name.

type Packed

type Packed struct {
	// Path is the packed tar, owner-only, which Remove deletes.
	Path   string
	Size   int64
	Digest string
	// contains filtered or unexported fields
}

Packed is a payload packed into a file of its own, ready to send.

func Pack

func Pack(entries []Entry) (*Packed, error)

Pack packs entries into a tar in a private temporary directory and answers its size and digest. Packing first, rather than while sending, means a file that changes meanwhile cannot make the stream disagree with the size the job names.

func (*Packed) Open

func (p *Packed) Open() (*os.File, error)

Open opens the packed tar for sending.

func (*Packed) Remove

func (p *Packed) Remove()

Remove deletes the packed tar.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL