Reuse PlatformClient instead of creating ephemeral instances per request #3233
eugenioenko
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Context
In the web-sdk, several internal functions create a new
PlatformClientinstance for every request. Each call constructs a new Connect RPC transport, new interceptor chain, and new service clients — all to make a single RPC call and then throw the client away.Where this happens
access-rpc.ts—fetchWrappedKey()andfetchKeyAccessServers()each create anew PlatformClient()policy/discovery.ts—listAttributes(),validateAttributes(),attributeExists(),attributeValueExists()each create anew PlatformClient()policy/api.ts—attributeFQNsAsValues()andgetRootCertsFromNamespace()each create anew PlatformClient()A single decrypt operation can trigger multiple rewrap calls (one per KAS in a split-key policy), each creating its own PlatformClient.
Proposal
OpenTDFshould own a singlePlatformClientinstance and pass it down toTDF3Client→tdf.ts→access.ts→access-rpc.tsand the policy functions.This would:
OpenTDFowns the client lifecycleWhat it would look like
Internal functions would change from:
To:
Considerations
access-fetch.tsdoesn't usePlatformClient, so it would still need auth config separatelyfetchKasPubKeyandfetchKasBasePubKeycreate unauthenticatedPlatformClientinstances (no auth needed for public key endpoints) — these could stay as-is or use a shared unauthenticated clientAuthConfigthrough the layersBeta Was this translation helpful? Give feedback.
All reactions