pub struct SessionSetup {
pub policy: Arc<ReceivePolicy>,
pub hooks: Option<Arc<dyn ReceiveHooks>>,
}Expand description
The receive policy and the hooks that ReceiveAuth::open gives to a
session.
Fields§
§policy: Arc<ReceivePolicy>The receive policy of the session.
hooks: Option<Arc<dyn ReceiveHooks>>The hooks of the session, or None for a session with no hooks.
The endpoint opens the session with
ReceiveService::hello_with_hooks.
The commit of the session calls ReceiveHooks::before_update, or
ReceiveHooks::before_server_commit for a server commit, before the
update lock. It calls ReceiveHooks::after_update after it releases
the update lock.
§Refusals and errors of a hook
- A refusal of
before_updateorbefore_server_commitwithHookRefusal::deniedgets 422 withref-denied. Hooks that do not implementbefore_server_commitrefuse each server commit in this way. - A refusal of
before_updateorbefore_server_commitwithHookRefusal::internalgets 500 withinternal. - An error of
after_updategets 500 withinternal. The refs and the detached metadata stay written, and the session ends as aborted. The endpoint does not callEndpointOptions::on_report.
The client gets the message of the refusal or of the error in the
Error frame, as the hook wrote it, cut at 4096 bytes. The host must
not put secrets or internal details in the message, because the
client sees it.
§Session state during a hook
While a hook runs, the session commits:
- It keeps its slot of
EndpointOptions::max_sessions. - The idle timeout, a
DELETE, andReceiveEndpoint::shutdowndo not end it. - During
before_updateorbefore_server_commit, it also holds a shared lock of the repository, so a prune waits.
Because the response to commit waits for both hooks, the host must
limit the time of its hooks.
§Checks after the hook
The commit runs these checks after before_update returns its plan,
so a commit can fail after a plan from the hook:
- Before the update lock, a plan that the checks refuse gets 500 with
internal.ReceiveHooksstates the checks of the plan. - Before the update lock, a merged dict with the host entries that is
larger than the size limit gets 422 with
limit-exceeded. - Under the update lock, these updates get 422 with
ref-denied:- a ref that is an alias
- a path that a ref write cannot replace
- two updates of which one names a directory of the other
- Under the update lock,
ref-mismatchandnon-fast-forwardget 409, anddelete-deniedgets 422. - Under the update lock, if the stored dict changed after the plan, a
merged dict over the size limit gets 422 with
limit-exceeded.
The commit of a server commit runs these checks after
before_server_commit returns:
- Under the update lock, the checks of the ref paths get 422 with
ref-denied. - Under the update lock,
orphanon a branch that is present, which the policy does not allow, gets 409 withnon-fast-forward. - Under the update lock, a tag that is present gets 409 with
ref-mismatch. - Under the update lock, if the stored dict of a staged attachment
changed after the size check before the hook, a merged dict over the
size limit gets 422 with
limit-exceeded.