actix / actix/actix-web

lazy data type

Offen
#2,285 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
A-web C-feature
Vorherrschende Sprache
Rust
Sterne
24.8k
Forks
1.9k
Ø Merge
23 Std. 10 Min.
Gemergte PRs (30 T.)
26

Beschreibung

## Motivation
The ~now deprecated~ `App::data_factory` method ~was is not very useful because it ran the~ runs futures to completion before starting the server up. For semi-expensive constructions it can be beneficial to delay their creation until a request needs it for the first time.

For example: especially in development when using debug builds, operations such as key derivation are very slow and are often only needed for a small set of endpoints. If you can afford a single slow op (per-worker) at app startup then such a type is useful. Otherwise, constructing the type before server creation is necessary.

## Solution
A way to lazily initalize data maybe built in Tokio's new OnceCell type: `LazyData`.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.