LiveStyle.Storage (LiveStyle v0.13.1)

View Source

File-based storage for the LiveStyle manifest.

Provides simple file-based manifest persistence using atomic file operations and file locking for safe concurrent access during compilation.

How It Works

  • Reads/writes go directly to the manifest file
  • Directory-based file locking prevents race conditions during parallel compilation
  • Atomic file operations (write to temp, rename) prevent corruption
  • Per-process state provides test isolation

Configuration

Configure the manifest path in your config:

config :live_style,
  manifest_path: "_build/live_style/manifest.etf"

The default path is "_build/live_style/manifest.etf".

Summary

Functions

Clears the manifest, resetting to empty state.

Clears the per-process path override.

Forks the current manifest into this process for test isolation.

Returns the current manifest path.

Returns whether this process has an active local manifest.

Reads the manifest from storage.

Sets the manifest path for the current process.

Atomically updates the manifest.

Writes the manifest to storage.

Functions

clear()

@spec clear() :: :ok

Clears the manifest, resetting to empty state.

clear_path()

@spec clear_path() :: :ok

Clears the per-process path override.

fork()

@spec fork() :: :ok

Forks the current manifest into this process for test isolation.

After calling this, all operations use the process-local copy.

path()

@spec path() :: String.t()

Returns the current manifest path.

process_active?()

@spec process_active?() :: boolean()

Returns whether this process has an active local manifest.

read()

@spec read() :: LiveStyle.Manifest.t()

Reads the manifest from storage.

Returns an empty manifest if storage is empty or uninitialized.

set_path(path)

@spec set_path(String.t()) :: :ok

Sets the manifest path for the current process.

update(fun)

@spec update((LiveStyle.Manifest.t() -> LiveStyle.Manifest.t())) :: :ok

Atomically updates the manifest.

The update function receives the current manifest and returns the new manifest. Uses file locking to prevent race conditions during parallel compilation.

write(manifest)

@spec write(LiveStyle.Manifest.t()) :: :ok

Writes the manifest to storage.