TenantProtocol
Protocol for tenant resolution and attribute retrieval.
Implementations must provide:
- get_current_tenant(): Resolve tenant from request context
- get_tenant_attributes(): Fetch tenant-specific attributes
Two standard implementations:
- ImplicitTenantAdapter: Single-tenant mode (Indie)
- HeaderTenantAdapter: Multi-tenant from gateway headers (Enterprise)
Example:
class MyTenantAdapter:
def get_current_tenant(self) -> str:
return "my-tenant"
def get_tenant_attributes(self, tenant_id: str) -> dict[str, Any]:
return {"plan": "pro"}
Source: tenant.py
Methods
get_current_tenant
def get_current_tenant(self) -> str
Get the current tenant ID from request context.
Returns:
Tenant identifier string
get_tenant_attributes
def get_tenant_attributes(self, tenant_id: str) -> dict[str, Any]
Get attributes for a specific tenant.
Args:
tenant_id: Tenant identifier
Returns:
Dict of tenant attributes (plan, features, flags, etc.)