Support for Independent Configuration Instances
Closed this issue · 3 comments
Currently, the fal library manages configuration through a global object. This approach causes conflicts when multiple instances need different configurations. Each call to the config function overwrites the global configuration, affecting all instances.
Use Case:
I have an application where each user configures their own API key. Due to the global nature of the config object, setting the configuration for one user affects all users, leading to unintended behavior.
Proposed Solution:
I propose that the fal library should support independent configuration instances. This could be achieved by allowing the creation of separate client instances, each with its own configuration. This way, multiple instances can coexist without interfering with each other's settings.
Benefits:
Isolation: Each instance will have its own configuration, preventing conflicts.
Flexibility: Users can manage different configurations for different use cases within the same application.
Scalability: This change will make the library more scalable and easier to integrate into larger applications.
Thank you for considering this feature request. I am happy to provide further details or assist in any way to make this possible.
Best regards,
Hey @Abel1011 , thanks for your feedback.
Long story short, this is an architecture we will adopt on the 1.0.0
client, along with some other breaking changes. But there's no ETA for that yet.
However, regarding this:
Due to the global nature of the config object, setting the configuration for one user affects all users
Can you clarify how the application is structured? Because usually in JS apps, each user has their own session/state which is not shared with other users, so although I agree with the benefits listed by you, I would not expect that the current implementation would have the issue described here. Global config doesn't mean shared in this context.
In the meantime, you could potentially relly on the credentials
being a resolver function instead of a fixed string. That is supported today:
fal.config({
credentials: () => {
// resolve API key and return
}
});