Help us shape the future of Go! Take the 2026 Go Developer Survey

artifact

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package artifact stores generated exports outside MCP tool responses.

Index

Constants

View Source
const (
	// DefaultTTL is how long a generated export remains downloadable.
	DefaultTTL = 15 * time.Minute
	// DefaultMaxBytes bounds one artifact when the operator does not set a limit.
	DefaultMaxBytes = 100 * 1024 * 1024
	// DefaultMaxTotalBytes bounds all live artifacts together.
	DefaultMaxTotalBytes = 500 * 1024 * 1024
	// DefaultMaxFiles bounds the number of live artifacts.
	DefaultMaxFiles = 100
	// DefaultMaxConcurrent bounds simultaneous database exports.
	DefaultMaxConcurrent = 2
)

Variables

View Source
var ErrCapacity = errors.New("export store capacity exhausted")

ErrCapacity is returned when aggregate export capacity is exhausted.

View Source
var ErrTooLarge = errors.New("export exceeds the byte limit")

ErrTooLarge is returned when an export exceeds the configured byte limit.

Functions

This section is empty.

Types

type Metadata

type Metadata struct {
	ID        string    `json:"export_id"`
	Filename  string    `json:"filename"`
	Size      int64     `json:"size_bytes"`
	SHA256    string    `json:"sha256"`
	ExpiresAt time.Time `json:"expires_at"`
}

Metadata is the small, data-free description returned to MCP clients.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store owns short-lived export files and serves them by unguessable ID.

func NewStore

func NewStore(root string, ttl time.Duration, maxBytes, maxTotalBytes int64, maxFiles, maxConcurrent int) (*Store, error)

NewStore creates an export store. An empty root gets a private temporary directory.

func (*Store) Close

func (s *Store) Close() error

Close stops cleanup and removes every artifact created by this process.

func (*Store) Create

func (s *Store) Create(ctx context.Context, filename string, write func(io.Writer) error) (*Metadata, error)

Create writes an artifact privately and publishes it only after write succeeds.

func (*Store) ServeHTTP

func (s *Store) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP downloads an artifact. The random ID is a short-lived capability.

Jump to

Keyboard shortcuts

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