init_hook

Attribute Macro init_hook 

Source
#[init_hook]
Expand description

Mark function to run at wasm initialization

In Rust it’s uncommon to have init hooks. For most global initialization you can use once_cell’s or lazy_static’s.

There are two cases where init hooks are needed:

  1. To register handlers. In most cases, more specific registrators should be used though (e.g. web_handler).
  2. For smaller latency during request processing (but see below).

§Influence on Request Latency

Note: while we will provide request processing latency metric distinct from the initialization time, this may not have the desired effect on users’ experience. When request comes in and there is no preinitialized worker, it’s likely that user request will need to wait for worker initialization. (We can also employ some techniques to optimize this too).