Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Add method for creating isolated client instances with custom configurations #110

Open
mgm1313 opened this issue Oct 5, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@mgm1313
Copy link

mgm1313 commented Oct 5, 2024

We're building a multi-tenant app where one server handles requests from different tenants. Each tenant has its own base_url for connections. Currently, we're using Skiffa to create agents like this:

export async function createAgent({
  domain,
  locale,
}: AgentProps) {
  const baseUrl = someLogicToDetermineBaseUrl(domain) 
  sdk.client.defaultClientConfiguration.baseUrl = new URL(baseUrl);
  const agent = sdk.client;
  return agent;
}

This approach has potential issues:

  • It modifies a global configuration (defaultClientConfiguration).
  • Parallel requests could overwrite each other's configurations, leading to race conditions and incorrect baseUrl assignments.

I would love the sdk.client to accept configuration on instantiation, allowing for per-request configurations:

export async function createAgent({
  domain,
  locale,
}: AgentProps) {
  const baseUrl = someLogicToDetermineBaseUrl(domain) 
  const agent = new sdk.client({
    defaultConfiguration: {baseUrl: new URL(baseUrl)}
  });
  return agent;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants