v2 / vlib / context / onecontext / README.md
40 lines · 26 sloc · 1.04 KB · f7926ec9a4320cc708f816a964b237d3c3587a10
Raw

onecontext

A library to merge existing V contexts.

Overview

Have you ever faced the situation where you have to merge multiple existing contexts? If not, then you might, eventually.

For example, we can face the situation where we are building an application using a library that gives us a global context. This context expires once the application is stopped.

Meanwhile, we are exposing a service like this:

fn (f Foo) get(ctx context.Context, bar Bar) ?Baz {
    . . .
}

Here, we receive another context provided by the service.

Then, in the get implementation, we want for example to query a database and we must provide a context for that.

Ideally, we would like to provide a merged context that would expire either: