Skip to main content

Lifecycle

WorkaDB exposes a host-driven lifecycle. The host is responsible for initialization, issuing requests, and shutting down the engine.

Initialization

  1. The host calls wepg_init with a wepg_config that includes the pgdata_path and tmp_path.
  2. If the data directory does not exist, wepg_init performs a template-based initdb unless WEPG_FLAG_NO_AUTO_INITDB is set.
  3. The host may call wepg_initdb explicitly to force initialization.

Execution

The host executes SQL by calling wepg_step with a SQL request. Each step is processed synchronously and returns a response buffer.

Reset and shutdown

  • wepg_reset clears session state without destroying the data directory.
  • wepg_shutdown releases resources and closes the engine. The host must not use the handle after shutdown.

This explicit lifecycle makes WorkaDB safe for mobile foreground and background transitions.