Virtual FileSystem (VFS)
aah introduced the Virtual FileSystem (VFS) feature in v0.11.0 aahframe.work/vfs
.
- In-memory FileSystem
- Ability to
mount
FileSystem directory into application virtual directory - The
mounted
virtual directory is accessible viaaah.App().VFS()
within aah application - A single consistent APIs for accessing Virtual and Physical FileSystem
Table of Contents
- Quick glance of supported VFS APIs
- Common Facts of VFS for Single and Non-Single Binary
- For Single Binary
- For Non-Single Binary
- Adding Custom Directory Mount
Quick glance of supported VFS APIs
The signatures are the same as the standard Go filesystem APIs (package os
, filepath
and ioutil
).
File Interface returned by aah.App().VFS().Open()
Specific Case Interface
Common Fact of VFS for Single and Non-Single Binary
- By default, aah mounts the application base directory as
/app
. - Application base directory and its sub-directories are accessible via
/app/**
- For e.g.: accessing
/app/config/aah.conf
aah.App().VFS().Open(path.Join(aah.App().VirtualBaseDir(), "config", "aah.conf"))
- For e.g.: accessing
- All the mounted directories are accessible via
aah.App().VFS()
.
For Single Binary
- The mounted directories get embedded into aah’s single binary when built with
aah build --single
oraah b -s
. - Embed packaging uses same exclusion list from config
build.excludes
. - During the development phase, VFS loads files and directories from Physical FileSystem. Basically, the
aah run
command. - It appropriately does
Gzip compression
, while embedding files into binary. - Static Files delivery - serves Gzip file data. No decompression is done at this stage.
- The embedded file path can be searchable via aah application binary using command
<app-binary> vfs find --pattern "regex pattern"
. This is the trivial way to know which files have got embedded into the binary.
Note: Anti-viruses software(s) may considers Go binary byte code source files as a threat, so it would clean/delete generate files that would cause aah CLI to fail/hang. Add $GOPATH or particular aah application path as exclusion in the anti-virus.
For Non-Single Binary
- VFS always loads files and directories from Physical FileSystem.
- Mounted directories
does not
get packed in the Zip archive, during theaah build
phase. Only the mount entry details are added into the aah binary.- Ensure that the mounted directories Physical Path does exist on the targeted deploy machine.
Adding Custom Directory Mount
Configuration goes into aah.project
(generated by command aah new
).