NewTypesenseClient initializes and returns a new Typesense client instance.
(apiKey string, hosts []string)
| 159 | |
| 160 | // NewTypesenseClient initializes and returns a new Typesense client instance. |
| 161 | func NewTypesenseClient(apiKey string, hosts []string) *TypesenseClient { |
| 162 | client := typesense.NewClient( |
| 163 | typesense.WithServer(hosts[0]), |
| 164 | typesense.WithAPIKey(apiKey), |
| 165 | typesense.WithConnectionTimeout(5*time.Second), |
| 166 | typesense.WithCircuitBreakerMaxRequests(50), |
| 167 | typesense.WithCircuitBreakerInterval(2*time.Minute), |
| 168 | typesense.WithCircuitBreakerTimeout(1*time.Minute), |
| 169 | ) |
| 170 | return &TypesenseClient{Client: client} |
| 171 | } |
| 172 | |
| 173 | // EnsureCollectionsExist ensures that all the necessary collections exist in the Typesense schema. |
| 174 | // If a collection doesn't exist, it will create the collection based on the latest schema. |
no outgoing calls
no test coverage detected