materialize

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CleanupFunc

type CleanupFunc func()

CleanupFunc releases resources created during materialization (for example temp files).

func MaterializeContentURL

func MaterializeContentURL(ctx context.Context, rawURL string, opts *Options) (localPath string, cleanup CleanupFunc, err error)

MaterializeContentURL resolves a content URL to a readable local filesystem path. For file:// URLs the underlying path is returned without copy and cleanup is a no-op. For http(s) and data URLs a bounded temp file is created; callers must invoke cleanup when done.

type DispatchCache

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

DispatchCache materializes each URL at most once per dispatch; call Release when dispatch completes.

func NewDispatchCache

func NewDispatchCache() *DispatchCache

NewDispatchCache returns an empty per-dispatch materialization cache.

func (*DispatchCache) MaterializeContentURL

func (c *DispatchCache) MaterializeContentURL(ctx context.Context, rawURL string, opts *Options) (localPath string, cleanup CleanupFunc, err error)

MaterializeContentURL returns a cached local path when rawURL was already materialized in this cache.

func (*DispatchCache) Release

func (c *DispatchCache) Release()

Release runs cleanup for all materialized URLs in this cache.

type Options

type Options struct {
	MaxBytes         int64
	Timeout          time.Duration
	MaxRedirects     int
	AllowPrivateURLs bool
	HTTPClient       *http.Client
	TempDir          string
}

Options configures MaterializeContentURL behavior.

type URLMaterializationCase

type URLMaterializationCase struct {
	Name         string                            `json:"name"`
	Setup        string                            `json:"setup,omitempty"`
	URL          string                            `json:"url,omitempty"`
	FileContent  string                            `json:"fileContent,omitempty"`
	ResponseBody string                            `json:"responseBody,omitempty"`
	ContentType  string                            `json:"contentType,omitempty"`
	StatusCode   int                               `json:"statusCode,omitempty"`
	MaxBytes     int64                             `json:"maxBytes,omitempty"`
	Expect       URLMaterializationCaseExpectation `json:"expect"`
}

URLMaterializationCase is one regression fixture for MaterializeContentURL.

type URLMaterializationCaseExpectation

type URLMaterializationCaseExpectation struct {
	Outcome              string   `json:"outcome"`
	ErrorContains        []string `json:"errorContains,omitempty"`
	SameAsLocalPath      bool     `json:"sameAsLocalPath,omitempty"`
	BodyMatch            bool     `json:"bodyMatch,omitempty"`
	TempPrefix           string   `json:"tempPrefix,omitempty"`
	TempRemovedOnCleanup bool     `json:"tempRemovedOnCleanup,omitempty"`
}

URLMaterializationCaseExpectation describes the expected materialization outcome.

type URLMaterializationCorpus

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

URLMaterializationCorpus is the cached materialization regression fixture set.

func LoadURLMaterializationCorpus

func LoadURLMaterializationCorpus() (URLMaterializationCorpus, error)

LoadURLMaterializationCorpus returns the shared URL materialization fixture corpus.

func (URLMaterializationCorpus) Case

Case returns the named fixture.

func (URLMaterializationCorpus) Cases

Cases returns all fixtures in file order.

Jump to

Keyboard shortcuts

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