storage

package
v0.58.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2025 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package storage provides data storage for the extension and user specific data.

Index

Constants

View Source
const K6BrowserDataDirPattern = "k6browser-data-*"

K6BrowserDataDirPattern is the pattern used to create the temporary directory for the browser data.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dir

type Dir struct {
	Dir string // path to the data storage directory
	// contains filtered or unexported fields
}

Dir manages data storage for the extension and user specific data on the local filesystem.

func (*Dir) Cleanup

func (d *Dir) Cleanup() error

Cleanup removes the temporary directory if Make was called with a non empty dir argument. It is named as Cleanup because it can be used for other features in the future.

func (*Dir) Make

func (d *Dir) Make(tmpDir string, dir any) error

Make creates a new temporary directory in tmpDir, and stores the path to the directory in the Dir field. When the dir argument is not empty, no directory will be created and it will not be deleted if Cleanup is called.

type LocalFilePersister

type LocalFilePersister struct{}

LocalFilePersister will persist files to the local disk.

func (*LocalFilePersister) Persist

func (l *LocalFilePersister) Persist(_ context.Context, path string, data io.Reader) (err error)

Persist will write the contents of data to the local disk on the specified path. TODO: we should not write to disk here but put it on some queue for async disk writes.

type PresignedURLResponse

type PresignedURLResponse struct {
	Service string `json:"service"`
	URLs    []struct {
		Name         string            `json:"name"`
		PresignedURL string            `json:"pre_signed_url"` //nolint:tagliatelle
		Method       string            `json:"method"`
		FormFields   map[string]string `json:"form_fields"` //nolint:tagliatelle
	} `json:"urls"`
}

PresignedURLResponse holds the response from a presigned generation request.

type RemoteFilePersister

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

RemoteFilePersister is to be used when files created by the browser module need to be uploaded to a remote location. This uses a presignedURLRequestURL to retrieve one presigned URL. The presigned url is used to upload the file to the remote location.

func NewRemoteFilePersister

func NewRemoteFilePersister(
	presignedURLRequestURL string,
	headers map[string]string,
	basePath string,
) *RemoteFilePersister

NewRemoteFilePersister creates a new instance of RemoteFilePersister.

func (*RemoteFilePersister) Persist

func (r *RemoteFilePersister) Persist(ctx context.Context, path string, data io.Reader) (err error)

Persist will upload the contents of data to a remote location.

Jump to

Keyboard shortcuts

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