Virtual FileSystem (VFS)
aah introduced the Virtual FileSystem (VFS) feature in v0.11.0 aahframework.org/vfs
.
- In-memory FileSystem
- Ability to
mount
FileSystem directory into virtual directory - The
mounted
virtual directory is accessible viaaah.AppVFS()
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.AppVFS().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.AppVFS().Open(path.Join(aah.AppVirtualBaseDir(), "config", "aah.conf"))
- For e.g.: accessing
- All the mounted directories are accessible via
aah.AppVFS()
.
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 flag
-list "regex pattern"
. This is the trivial way to know which files have got embedded into the binary.
Note: Antiviruses 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 application path as exclusion in the antivirus.
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 Physical Path does exist on the deployed machine.
Adding Custom Directory Mount
Configuration goes in aah.project
(generated by command aah new
).