Repository navigation
feat: Accept synchronous hooks on the async client - #548
Draft
jsonbailey wants to merge 2 commits into
Draft
jsonbailey wants to merge 2 commits into
jsonbailey wants to merge 2 commits into
Conversation
AsyncLDClient now takes the same ldclient.hook.Hook as LDClient, so integrations such as the OpenTelemetry tracing hook work with it. The hook stages run synchronously in the caller's task, so a span made current in the before stage stays current until the after stage. AsyncHook is removed. AsyncPlugin keeps its async register(), and its get_hooks() returns Hook instances. AsyncConfig now raises TypeError for a hook that is not a Hook or a plugin that is not an AsyncPlugin, which matches add_hook().
Match the sync client: AsyncConfig and add_hook() ignore items of the wrong type. The async contract-test service uses the sync PostingHook. Remove redundant docstring notes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: Remove the experimental AsyncHook class
Summary
AsyncLDClientnow uses the sameldclient.hook.HookasLDClient, so existing integrations such as the OpenTelemetry tracing hook work with the async client. Before this change, the async client accepted onlyAsyncHookand ignored sync hooks.AsyncHookis removed. The async API is experimental.AsyncPluginkeeps its asyncregister(). Itsget_hooks()now returnsHookinstances.AsyncConfigandadd_hook()ignore items of the wrong type, the same as the sync client.PostingHook.