Skip to main content

Module daemon

Module daemon 

Source
Expand description

Daemon subsystem for TLDR CLI

Provides a persistent background process that holds indexes in memory for fast queries, implements Salsa-style query memoization, and tracks usage statistics.

§Architecture

+-----------------------------------------------------------------+
|                          CLI Layer                               |
|  daemon start | stop | status | query | notify | stats | warm   |
+-----------------------------------------------------------------+
                               |
                   +-----------v-----------+
                   |    IPC Transport      |
                   |  Unix Socket (Unix)   |
                   |  TCP Socket (Windows) |
                   +-----------+-----------+
                               |
+-----------------------------------------------------------------+
|                        TLDRDaemon                                |
|  +-------------+  +-------------+  +-------------+              |
|  | SalsaDB     |  | Dedup Index |  | Stats Store |              |
|  | (memoize)   |  | (content-   |  | (per-session|              |
|  |             |  |  hash)      |  |  tracking)  |              |
|  +-------------+  +-------------+  +-------------+              |
+-----------------------------------------------------------------+

§Modules

  • types: Core data types for configuration, status, and statistics
  • error: Error types for daemon operations
  • pid: PID file locking for daemon singleton enforcement
  • ipc: IPC client/server for socket communication
  • salsa: Salsa-style incremental computation cache
  • daemon: Main daemon process and command handlers
  • start: Daemon start command
  • stop: Daemon stop command
  • status: Daemon status command
  • query: Low-level query passthrough command
  • notify: File change notification command
  • warm: Cache warming command
  • stats: Usage statistics command
  • cache_stats: Cache statistics command
  • cache_clear: Cache clearing command

Re-exports§

pub use daemon_impl as daemon;
pub use error::DaemonError;
pub use error::DaemonResult;
pub use ipc::check_socket_alive;
pub use ipc::cleanup_socket;
pub use ipc::read_command;
pub use ipc::send_command;
pub use ipc::send_raw_command;
pub use ipc::send_response;
pub use ipc::validate_socket_path;
pub use ipc::IpcListener;
pub use ipc::IpcStream;
pub use ipc::CONNECTION_TIMEOUT_SECS;
pub use ipc::MAX_MESSAGE_SIZE;
pub use ipc::READ_TIMEOUT_SECS;
pub use pid::check_stale_pid;
pub use pid::cleanup_stale_pid;
pub use pid::compute_hash;
pub use pid::compute_pid_path;
pub use pid::compute_socket_path;
pub use pid::is_process_running;
pub use pid::try_acquire_lock;
pub use pid::PidGuard;
pub use salsa::hash_args;
pub use salsa::hash_path;
pub use salsa::CacheEntry;
pub use salsa::QueryCache;
pub use salsa::QueryKey;
pub use salsa::DEFAULT_MAX_ENTRIES;
pub use types::AllSessionsSummary;
pub use types::CacheFileInfo;
pub use types::DaemonCommand;
pub use types::DaemonConfig;
pub use types::DaemonResponse;
pub use types::DaemonStatus;
pub use types::DedupStats;
pub use types::GlobalStats;
pub use types::HookStats;
pub use types::SalsaCacheStats;
pub use types::SessionStats;
pub use types::DEFAULT_REINDEX_THRESHOLD;
pub use types::HOOK_FLUSH_THRESHOLD;
pub use types::IDLE_TIMEOUT;
pub use types::IDLE_TIMEOUT_SECS;
pub use daemon_impl::TLDRDaemon;
pub use cache_clear::CacheClearArgs;
pub use cache_stats::CacheStatsArgs;
pub use notify::DaemonNotifyArgs;
pub use query::DaemonQueryArgs;
pub use start::DaemonStartArgs;
pub use stats::StatsArgs;
pub use status::DaemonStatusArgs;
pub use stop::DaemonStopArgs;
pub use warm::WarmArgs;

Modules§

cache_clear
Cache clear command implementation
cache_stats
Cache statistics command implementation
daemon_impl
Core daemon state machine and runtime
error
Daemon-specific error types
ipc
Cross-platform IPC layer for daemon communication
notify
Daemon notify command implementation
pid
PID file locking for daemon singleton enforcement
query
Daemon query command implementation
salsa
Salsa-style incremental computation cache
start
Daemon start command implementation
stats
Stats command implementation
status
Daemon status command implementation
stop
Daemon stop command implementation
types
Core types for the TLDR daemon subsystem
warm
Warm command implementation