Documentation
¶
Overview ¶
Package files owns source Files: Project-owned uploaded bytes with immutable metadata, independent of Sessions and of the workspace copies made from them. It defines their vocabulary, the upload and listing rules, and the create and delete use cases, and declares the storage they need.
Index ¶
Constants ¶
const ( // MaxBytes bounds the content of one File. MaxBytes int64 = 512 << 20 // MaxPageSize bounds one List page. MaxPageSize = 10000 // PurposeUserData is the only purpose Core stores. PurposeUserData = "user_data" )
Variables ¶
var ( // ErrNotFound reports a File the tenant does not own, including a malformed // or foreign ID, so missing and foreign Files are indistinguishable. ErrNotFound = errors.New("file not found") // ErrInvalidInput reports an upload envelope, list query or tenant that // Core does not accept. ErrInvalidInput = errors.New("invalid file request") // ErrTooLarge reports content beyond the operation's limit. ErrTooLarge = errors.New("file exceeds the content limit") // ErrEmpty reports an upload without content. ErrEmpty = errors.New("file is empty") )
Functions ¶
Types ¶
type CreateCommand ¶
CreateCommand uploads one File. Upload writes the content to the writer it receives and returns the envelope read with it.
type DeleteCommand ¶
DeleteCommand deletes one File.
type ListQuery ¶
type ListQuery struct {
// After is the ID of the previous page's last File, or empty for the first
// page.
After string
Limit int
Ascending bool
// Purpose, when not nil, keeps only Files with this purpose.
Purpose *string
}
ListQuery selects one page of a tenant's Files, ordered by creation time and then ID.
type Page ¶
Page is one List page. NextCursor is the ID of its last File when more Files follow, and empty otherwise.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service runs the File use cases that change stored state.
func NewService ¶
type Storage ¶
type Storage interface {
// Create allocates the content, calls write with a writer for it, and stores
// the File with the returned envelope only when write returns nil. A
// storage failure while writing takes precedence over write's own error.
Create(ctx context.Context, tenantID string, write func(io.Writer) (Upload, error)) (File, error)
// Delete removes the File and its content, or returns ErrNotFound.
Delete(ctx context.Context, tenantID, fileID string) error
}
Storage persists Files. Each method runs in one transaction.