Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement the File API's open method, base File abstraction and File.stat operation. #3142

Closed
Tracked by #3141
oleiade opened this issue Jun 27, 2023 · 0 comments · Fixed by #3165
Closed
Tracked by #3141
Assignees
Milestone

Comments

@oleiade
Copy link
Member

oleiade commented Jun 27, 2023

As part of #3141, implementing the agreed-upon design for k6's File API, we intend to:

  1. declare a dedicated experimental k6 module
  2. add an open function to it, as specified
  3. add an almost empty vessel File abstraction so that the open method does return an object, albeit not functional as part of this iteration.
  4. implement the File.stat method to retrieve file information about the file itself
  5. implement the FileInfo abstraction to fulfill 👆

Details

In this implementation step, we should declare and implement the open function, as showcased in the dedicated design document. This function inputs a path string and returns a Promises resolving to a File instance. To give some minimal usefulness to the abstraction, we expect to have the File.stat method and its FileInfo construct counterparts exposed alongside it.

We expect the open function to perform all the underlying operations it should, regardless of whether we expose helpful methods on the resulting File object yet:

  • resolve, clean, and secure the path to the resource
  • ensure it exists and is accessible
  • open it
  • map the file descriptor and track it internally in the module, as described in the design doc, and in a fashion that allows us to fulfill the scope of the stat method.

The result would look something like this

open(path: string): Promise<File>

interface File {
	stat(): Promise<FileInfo>
}

interface FileInfo {
	name: string
	size: number
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant