Skip to main content

Module background

Module background 

Source
Expand description

Work that must not hold up the plugin’s hooks. A plugin runs one call at a time, so a slow lookup in login would keep chat waiting past its deadline. Instead the hook defers its answer, hands the lookup to a background worker and returns; the answer follows from job-done.

Functions§

defer
Call inside login, initial-server, before-transfer, command, chat or kick: the hook’s own return value is ignored, and the answer is the one given to resolve with the returned ticket. The hook’s deadline keeps running: an answer that comes too late counts as a missed deadline. An error outside those hooks, or when the call was deferred already.
is_worker
Whether this instance is a background worker.
resolve
Answer a deferred hook. Returns false when nobody waits for the ticket any more (the deadline passed, or it was answered).
run
Queue payload for the plugin’s background workers (manifest [background] workers, an error without any): one of them calls work(payload), and its result comes back through job-done with the returned handle. At most 1024 jobs wait at a time.

Type Aliases§

Decision