limited-ram-7754408/23/2023, 3:20 PM
Create a separate GrowthBook instance for every incoming request. This is easiest if you use a middleware:May I know why a separate instance needs to be instantiated for each request? Wouldn't this create many instances proportional to the traffic the server is handling? Is it possible to have a cached GrowthBook instance across the server and we just add it to the
property and override the attributes if required like
for incoming requests?
happy-autumn-4093808/23/2023, 4:24 PM
limited-ram-7754408/23/2023, 4:46 PM
property within the Express
object at a middleware level
Let's say you have a downstream service (e.g. serviceC) depending on a feature flag.
E.g. middleware -> controller -> serviceA -> serviceB -> serviceC
Does this mean that I need the pass the
object from req from the controller level all the way down to serviceC? This seems similar to "prop-drilling"
Is there a way serviceC can just obtain the singleton from the SDK?
I considered just initialising a new SDK instance in serviceC and reading the value of the flag. This would work for normal usage but not for percentage-based rollouts which would depend on the attributes set by the middleware layer (e.g. an authorization middleware that sets user-specific attributes like email and role).
Is there any recommended approach here?
happy-autumn-4093808/28/2023, 5:21 PM
object and passing that between services.
limited-ram-7754408/29/2023, 2:11 AM
as you suggested. Thanks for the input @happy-autumn-40938!