Skip to main content

start_watching

Function start_watching 

Source
pub fn start_watching(
    engine: Arc<Mutex<Option<Engine>>>,
    attachments: Arc<AttachRegistry>,
    registry: Arc<WatcherRegistry>,
    subscriptions: Option<Arc<SubscriptionRegistry>>,
    dir: PathBuf,
    table: String,
    target_db: Option<String>,
    options: WatchOptions,
) -> Result<WatcherStats, McpError>
Expand description

Begin watching dir. Builds a dedicated connection pool, runs the initial sweep (sequentially — there’s no benefit to parallelism for startup since the pool isn’t under load yet), then installs a notify watcher that streams events to an async tokio task. Returns a snapshot of the initial-sweep stats.

The engine Arc must point to an already-initialized engine (the caller in server.rs eagerly calls ensure_engine before invoking this).

§Errors

  • Returns ErrorCode::FileNotFound if dir does not exist, is not a directory, or cannot be canonicalized.
  • Returns ErrorCode::InternalError if the watcher registry mutex or engine mutex is poisoned, if the engine has not been initialized, if start_watching is not called from a Tokio runtime, or if the watcher pool / OS file-system watcher cannot be constructed.
  • Returns ErrorCode::InternalError wrapping the error string when notify::RecommendedWatcher setup fails.
  • Propagates any error from the initial sweep’s per-file ingest (file read, schema inference, or Hyper COPY / INSERT errors).