客户端添加切换租户

This commit is contained in:
cn-kali-team
2026-04-29 18:57:00 +08:00
committed by lyingbug
parent b3898eb101
commit 1e170793b3
4 changed files with 103 additions and 2 deletions
+7
View File
@@ -21,12 +21,19 @@ import (
// - Cleaning up resources
func ExampleUsage() {
// Create a client instance
tenantID := uint64(10000) // default tenant for all requests from this client
apiClient := NewClient(
"http://localhost:8080",
WithToken("your-auth-token"),
WithTimeout(30*time.Second),
WithTenantID(tenantID), // default tenant for all requests from this client
)
// Per-request tenant override example:
// You can override the tenant for a single request by setting the "TenantID" value in the context.
// e.g. ctx := context.WithValue(context.Background(), "TenantID", &tenantID)
// then pass `ctx` to any client method to use tenant 2 for that request only.
// 1. Create a knowledge base
fmt.Println("1. Creating knowledge base...")
kb := &KnowledgeBase{