wasm

package
v0.0.0-...-9f9bb61 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPurgeInterval         = 1 * time.Hour
	DefaultModuleExpiry          = 24 * time.Hour
	DefaultHTTPRequestTimeout    = 15 * time.Second
	DefaultHTTPRequestMaxRetries = 5
)

Variables

View Source
var PullPolicyValues = map[string]PullPolicy{
	"UNSPECIFIED_POLICY": 0,
	"IfNotPresent":       1,
	"Always":             2,
}

Functions

func MaybeConvertWasmExtensionConfig

func MaybeConvertWasmExtensionConfig(resources []*anypb.Any, cache Cache) error

MaybeConvertWasmExtensionConfig converts any presence of module remote download to local file. It downloads the Wasm module and stores the module locally in the file system.

Types

type Cache

type Cache interface {
	Get(url string, opts GetOptions) (string, error)
	Cleanup()
}

Cache models a Wasm module cache.

type GetOptions

type GetOptions struct {
	Checksum        string
	ResourceName    string
	ResourceVersion string
	RequestTimeout  time.Duration
	PullSecret      []byte
	PullPolicy      PullPolicy
}

GetOptions is a struct for providing options to Get method of Cache.

type HTTPFetcher

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

HTTPFetcher fetches remote wasm module with HTTP get.

func NewHTTPFetcher

func NewHTTPFetcher(requestTimeout time.Duration, requestMaxRetry int) *HTTPFetcher

NewHTTPFetcher create a new HTTP remote wasm module fetcher. requestTimeout is a timeout for each HTTP/HTTPS request. requestMaxRetry is # of maximum retries of HTTP/HTTPS requests.

func (*HTTPFetcher) Fetch

func (f *HTTPFetcher) Fetch(ctx context.Context, url string, allowInsecure bool) ([]byte, error)

Fetch downloads a wasm module with HTTP get.

type ImageFetcher

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

func NewImageFetcher

func NewImageFetcher(ctx context.Context, opt ImageFetcherOption) *ImageFetcher

func (*ImageFetcher) PrepareFetch

func (o *ImageFetcher) PrepareFetch(url string) (binaryFetcher func() ([]byte, error), actualDigest string, err error)

PrepareFetch is the entrypoint for fetching Wasm binary from Wasm Image Specification compatible images. Wasm binary is not fetched immediately, but returned by `binaryFetcher` function, which is returned by PrepareFetch. By this way, we can have another chance to check cache with `actualDigest` without downloading the OCI image.

type ImageFetcherOption

type ImageFetcherOption struct {
	// TODO(mathetake) Add signature verification stuff.
	PullSecret []byte
	Insecure   bool
}

func (ImageFetcherOption) String

func (o ImageFetcherOption) String() string

type LocalFileCache

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

LocalFileCache for downloaded Wasm modules. Currently it stores the Wasm module as local file.

func NewLocalFileCache

func NewLocalFileCache(dir string, options Options) *LocalFileCache

NewLocalFileCache create a new Wasm module cache which downloads and stores Wasm module files locally.

func (*LocalFileCache) Cleanup

func (c *LocalFileCache) Cleanup()

Cleanup closes background Wasm module purge routine.

func (*LocalFileCache) Get

func (c *LocalFileCache) Get(downloadURL string, opts GetOptions) (string, error)

Get returns path the local Wasm module file.

type Options

type Options struct {
	PurgeInterval         time.Duration
	ModuleExpiry          time.Duration
	InsecureRegistries    sets.String
	HTTPRequestTimeout    time.Duration
	HTTPRequestMaxRetries int
}

Options contains configurations to create a Cache instance.

type PullPolicy

type PullPolicy int32
const (
	Unspecified  PullPolicy = 0
	IfNotPresent PullPolicy = 1
	Always       PullPolicy = 2
)

Jump to

Keyboard shortcuts

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