LiveStyle.Storage (LiveStyle v0.14.0)
View SourceFile-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.
Clears the usage manifest, resetting to empty state.
Clears the per-process usage path override.
Forks the current manifest into this process for test isolation.
Forks the current usage 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.
Reads the usage manifest from storage.
Sets the manifest path for the current process.
Sets the usage manifest path for the current process.
Atomically updates the manifest.
Atomically updates the usage manifest.
Returns the current usage manifest path.
Returns whether this process has an active local usage manifest.
Writes the manifest to storage.
Writes the usage manifest to storage.
Functions
@spec clear() :: :ok
Clears the manifest, resetting to empty state.
@spec clear_path() :: :ok
Clears the per-process path override.
@spec clear_usage() :: :ok
Clears the usage manifest, resetting to empty state.
@spec clear_usage_path() :: :ok
Clears the per-process usage path override.
@spec fork() :: :ok
Forks the current manifest into this process for test isolation.
After calling this, all operations use the process-local copy.
@spec fork_usage() :: :ok
Forks the current usage manifest into this process for test isolation.
@spec path() :: String.t()
Returns the current manifest path.
@spec process_active?() :: boolean()
Returns whether this process has an active local manifest.
@spec read() :: LiveStyle.Manifest.t()
Reads the manifest from storage.
Returns an empty manifest if storage is empty or uninitialized.
@spec read_usage() :: LiveStyle.UsageManifest.t()
Reads the usage manifest from storage.
Returns an empty usage manifest if storage is empty or uninitialized.
@spec set_path(String.t()) :: :ok
Sets the manifest path for the current process.
@spec set_usage_path(String.t()) :: :ok
Sets the usage manifest path for the current process.
@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.
@spec update_usage((LiveStyle.UsageManifest.t() -> LiveStyle.UsageManifest.t())) :: :ok
Atomically updates the usage manifest.
The update function receives the current usage and returns the new usage. Uses file locking to prevent race conditions during parallel compilation.
@spec usage_path() :: String.t()
Returns the current usage manifest path.
@spec usage_process_active?() :: boolean()
Returns whether this process has an active local usage manifest.
@spec write(LiveStyle.Manifest.t()) :: :ok
Writes the manifest to storage.
@spec write_usage(LiveStyle.UsageManifest.t()) :: :ok
Writes the usage manifest to storage.