Skip to content

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

@mgm1313

Description

@mgm1313

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;
}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions