|
C++ Server-Side SDK
LaunchDarkly SDK
|
C bindings for passing caller data to hooks. More...
#include <launchdarkly/bindings/c/export.h>

Go to the source code of this file.
Typedefs | |
| typedef struct p_LDHookContext * | LDHookContext |
| Opaque hook context handle. More... | |
Functions | |
| LDHookContext_New (void) | |
| Create a new hook context. More... | |
| LDHookContext_Set (LDHookContext hook_context, char const *key, void const *value) | |
| Set a pointer value in the hook context. More... | |
| LDHookContext_Get (LDHookContext hook_context, char const *key, void const **out_value) | |
| Get a pointer value from the hook context. More... | |
| LDHookContext_Free (LDHookContext hook_context) | |
| Free a hook context. More... | |
C bindings for passing caller data to hooks.
HookContext allows application code to pass arbitrary data through to hooks. This is useful for propagating context like OpenTelemetry span parents in asynchronous web frameworks where thread-local storage doesn't work.
USAGE: Most applications don't need HookContext. Only use it when you need to pass data from the evaluation call site to your hooks, such as:
LIFETIME AND OWNERSHIP:
| typedef struct p_LDHookContext* LDHookContext |
Opaque hook context handle.
Created by LDHookContext_New(), must be freed with LDHookContext_Free().
| LDHookContext_Free | ( | LDHookContext | hook_context | ) |
Free a hook context.
| hook_context | Hook context to free. May be NULL (no-op). |
| LDHookContext_Get | ( | LDHookContext | hook_context, |
| char const * | key, | ||
| void const ** | out_value | ||
| ) |
Get a pointer value from the hook context.
Retrieves an application-specific pointer previously stored with LDHookContext_Set().
USAGE IN HOOKS:
| hook_context | Hook context. Must not be NULL. |
| key | Key to look up. Must be null-terminated UTF-8 string. Must not be NULL. |
| out_value | Pointer to receive the value. Must not be NULL. Set to NULL if key not found. |
| LDHookContext_New | ( | void | ) |
Create a new hook context.
| LDHookContext_Set | ( | LDHookContext | hook_context, |
| char const * | key, | ||
| void const * | value | ||
| ) |
Set a pointer value in the hook context.
Stores an application-specific pointer that can be retrieved by hooks. The lifetime of the pointed-to data must extend through the variation call.
EXAMPLE - OpenTelemetry span parent:
| hook_context | Hook context. Must not be NULL. |
| key | Key for the value. Must be null-terminated UTF-8 string. Must not be NULL. |
| value | Pointer to application data. May be NULL. Lifetime managed by caller - must remain valid through the variation call. |