Documentation ¶
Overview ¶
Package fs provides a k6 module that allows users to interact with files from the local filesystem as per the File API design document.
Index ¶
Constants ¶
const ( // NotFoundError is emitted when a file is not found. NotFoundError errorKind = iota + 1 // InvalidResourceError is emitted when a resource is invalid: for // instance when attempting to open a directory, which is not supported. InvalidResourceError // ForbiddenError is emitted when an operation is forbidden. ForbiddenError // TypeError is emitted when an incorrect type has been used. TypeError // EOFError is emitted when the end of a file has been reached. EOFError )
const ( // SeekModeStart sets the offset relative to the start of the file. SeekModeStart SeekMode = 0 // SeekModeCurrent seeks relative to the current offset. SeekModeCurrent = 1 // SeekModeEnd seeks relative to the end of the file. // // When using this mode the seek operation will move backwards from // the end of the file. SeekModeEnd = 2 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct { // Path holds the name of the file, as presented to [Open]. Path string `json:"path"` // contains filtered or unexported fields }
File represents a file and exposes methods to interact with it.
It is a wrapper around the [file] struct, which is meant to be directly exposed to the JS runtime.
func (*File) Read ¶
Read the file's content, and writes it into the provided Uint8Array.
Resolves to either the number of bytes read during the operation or EOF (null) if there was nothing more to read.
It is possible for a read to successfully return with 0 bytes. This does not indicate EOF.
type FileInfo ¶
type FileInfo struct { // Name holds the base name of the file. Name string `json:"name"` // Size holds the size of the file in bytes. Size int64 `json:"size"` }
FileInfo holds information about a file.
type ModuleInstance ¶
type ModuleInstance struct {
// contains filtered or unexported fields
}
ModuleInstance represents an instance of the fs module for a single VU.
func (*ModuleInstance) Exports ¶
func (mi *ModuleInstance) Exports() modules.Exports
Exports implements the modules.Module interface and returns the exports of our module.
type RootModule ¶
type RootModule struct {
// contains filtered or unexported fields
}
RootModule is the global module instance that will create instances of our module for each VU.
func (*RootModule) NewModuleInstance ¶
func (rm *RootModule) NewModuleInstance(vu modules.VU) modules.Instance
NewModuleInstance implements the modules.Module interface and returns a new instance of our module for the given VU.