Skip to main content

save_upstream

Function save_upstream 

Source
pub async fn save_upstream(
    pool: &PgPool,
    upstream: &Upstream,
) -> ProxyResult<Upstream>
Expand description

Insert an upstream and its backends, or replace them if the id is stored.

The upstream and its backend set are written in one transaction, and the backends are replaced wholesale rather than merged: Upstream::backends is the complete set, so a backend dropped from the value has to disappear from the database. Doing that outside a transaction would leave a window where the upstream has no backends at all and every request through it fails.