Skip to content

Commit

Permalink
In memory backend (#26)
Browse files Browse the repository at this point in the history
## [5.2.0] - 2019-07-16
### Added
- In-Memory backend vfs implementation
- Included the in-memory backend to the list of registered backends used in backend_integration_test
- Checking for existence at the start of various File functions (size, seek, etc) and returning and error if the file does not exist on the OS backend
- Tests in  backend_integration_test that ensure that operations done on non-existent files throw an error
- mem.md in vfs/docs, updated link to it in the README.md
### Fixed
- Relative path validation in utils.go now disallows empty names
### Changed
- utils_test.go now expects an empty string NOT to validate
- updated README to include "Touch()" definition under the File interface rather than the Location interface
- updated README to exclude "in-memory-backend" from the list of ideas
  • Loading branch information
moezeid authored and funkyshu committed Jul 17, 2019
1 parent 39c1de2 commit db1a6b5
Show file tree
Hide file tree
Showing 15 changed files with 2,499 additions and 11 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [5.2.0] - 2019-07-16
### Added
- In-Memory backend vfs implementation
- Included the in-memory backend to the list of registered backends used in backend_integration_test
- Checking for existence at the start of various File functions (size, seek, etc) and returning and error if the file does not exist on the OS backend
- Tests in backend_integration_test that ensure that operations done on non-existent files throw an error
- mem.md in vfs/docs, updated link to it in the README.md
### Fixed
- Relative path validation in utils.go now disallows empty names
### Changed
- utils_test.go now expects an empty string NOT to validate
- updated README to include "Touch()" definition under the File interface rather than the Location interface
- updated README to exclude "in-memory-backend" from the list of ideas


## [5.1.0] - 2019-07-08
### Added
- Added Touch() method to File interface and implemented in each backend.
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ Feel free to send a pull request if you want to add your backend to the list.
* [os backend](docs/os.md)
* [gs backend](docs/gs.md)
* [s3 backend](docs/s3.md)
* [in-memory backend](docs/mem.md)
* [utils](docs/utils.md)

### Ideas
Expand All @@ -142,7 +143,6 @@ Things to add:

* Add SFTP backend
* Add Azure storage backend
* Add in-memory backend
* Provide better List() functionality with more abstracted filering and paging (iterator?) Retrun File structs vs URIs?
* Add better/any context.Context() support

Expand Down Expand Up @@ -266,6 +266,10 @@ type File interface {
//
// For file:///some/path/to/file.txt, it would return file.txt
Name() string

// Touch creates a zero-length file on the vfs.File if no File exists. Update File's last modified timestamp.
// Returns error if unable to touch File.
Touch() error

// URI returns the fully qualified absolute URI for the File. IE, s3://bucket/some/path/to/file.txt
URI() string
Expand Down Expand Up @@ -302,7 +306,7 @@ type FileSystem interface {
NewLocation(volume string, absLocPath string) (Location, error)

// Name returns the name of the FileSystem ie: Amazon S3, os, Google Cloud Storage, etc.
Name() string
Name() string

// Scheme returns the uri scheme used by the FileSystem: s3, file, gs, etc.
Scheme() string
Expand Down Expand Up @@ -403,10 +407,6 @@ type Location interface {
// * Accepts relative file path.
DeleteFile(relFilePath string) error

// Touch creates a zero-length file on the vfs.File if no File exists. Update File's last modified timestamp.
// Returns error if unable to touch File.
Touch() error

// URI returns the fully qualified absolute URI for the Location. IE, s3://bucket/some/path/
//
// URI's for locations must always end with a slash.
Expand Down
20 changes: 20 additions & 0 deletions backend/mem/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
Package mem built-in mem lib VFS implementation.
Usage
Rely on github.com/c2fo/vfs/backend
import(
"github.com/c2fo/vfs/backend"
"github.com/c2fo/vfs/backend/mem"
)
func UseFs() error {
fs, err := backend.Backend(mem.Scheme)
...
}
Or call directly:
import _mem "github.com/c2fo/vfs/backend/mem"
func DoSomething() {
fs := _mem.NewFileSystem()
...
}
*/
package mem
Loading

0 comments on commit db1a6b5

Please sign in to comment.