Skip to main content

get_or_create_instance_id

Function get_or_create_instance_id 

Source
pub async fn get_or_create_instance_id(pool: &DbPool) -> Result<String, DbError>
Expand description

Fetch this database’s stable instance UUID, generating and persisting one on first call.

Race-safe: the insert is ON CONFLICT DO NOTHING, so the first writer’s row wins and every caller — including concurrent ones racing on a fresh database — reads back the same persisted value afterward.

§Errors

Returns DbError if the insert or the follow-up select fails.

§Examples

let instance_id = zeph_db::get_or_create_instance_id(pool).await?;