Disks
A disk is a POSIX filesystem stored in object storage. The data clients are using sits in Archil’s storage layer, in front of the bucket, so reads and writes run at disk speed while the bucket holds everything. A write is durable once fsync returns. The bucket is Archil’s, or your own.
One disk is reachable three ways at once: mounted as a filesystem, through serverless exec, and as an S3-style bucket of objects.
Create a disk for each user or session at run time, and declare the few shared ones in your Stack.
Create disks at run time
Section titled “Create disks at run time”Archil.CreateDisk gives a Worker or Lambda a client that creates disks by name:
const disks = yield* Archil.CreateDisk();const home = yield* disks.create(`user-${user}`);Calling create again with the same name returns the same disk. get, list, and delete work on the disks this client created.
Declare a shared disk
Section titled “Declare a shared disk”A dataset every user reads is a resource:
export const Dataset = Archil.Disk("Dataset", {});Restrict where it can be mounted from with allowedIps, and stop sandboxes and exec from mounting it with allowSandboxMount: false.
Run commands and search
Section titled “Run commands and search”const dataset = yield* Archil.ExecDisk(Dataset);const result = yield* dataset.exec("wc -l /mnt/archil/*.csv");const hits = yield* dataset.grep({ pattern: "TODO", directory: "src", recursive: true });ExecDisks mounts several disks in one call, at paths under /mnt/archil.
Read and write files without a machine
Section titled “Read and write files without a machine”Every disk is also an S3-style bucket. ReadDisk, WriteDisk, and ReadWriteDisk use it:
const files = yield* Archil.ReadWriteDisk(Dataset);yield* files.put("notes/today.md", "# Today");const url = yield* files.share("notes/today.md", 3600);A write that conflicts with a mounted client’s lock fails with ObjectConflict.
Branches and your own bucket
Section titled “Branches and your own bucket”Copy a disk per session from a checkpoint with Branches and checkpoints. Keep a disk’s files as ordinary objects in your S3 bucket with Your own bucket.