Skip to content

Commit e740584

Browse files
committed
we control config
1 parent d12d2ff commit e740584

File tree

3 files changed

+307
-358
lines changed

3 files changed

+307
-358
lines changed

templates/go/api.mustache

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ func WithContext(ctx context.Context) requestOption {
7171

7272
func WithHeaderParam(key string, value any) requestOption {
7373
return requestOption(func(c *config) {
74-
if c.headerParams == nil {
75-
c.headerParams = map[string]string{}
76-
}
77-
7874
c.headerParams[key] = utils.ParameterToString(value)
7975
})
8076
}

templates/go/search_helpers.mustache

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
func CreateIterable[T any](execute func(*T, error) (*T, error), validate func(*T, error) (bool, error), opts ...IterableOption) (*T, error) {
22
conf := config{
3+
headerParams: map[string]string{},
34
maxRetries: -1,
45
timeout: func(count int) time.Duration {
56
return 0 * time.Millisecond
@@ -204,7 +205,7 @@ func (c *APIClient) WaitForApiKey(
204205
operation ApiKeyOperation,
205206
opts ...WaitForApiKeyOption,
206207
) (*GetApiKeyResponse, error) {
207-
conf := config{}
208+
conf := config{headerParams: map[string]string{}}
208209

209210
for _, opt := range opts {
210211
opt.apply(&conf)
@@ -572,6 +573,7 @@ Helper: Replaces object content of all the given objects according to their resp
572573
*/
573574
func (c *APIClient) PartialUpdateObjects(indexName string, objects []map[string]any, opts ...PartialUpdateObjectsOption) ([]BatchResponse, error) {
574575
conf := config{
576+
headerParams: map[string]string{},
575577
createIfNotExists: true,
576578
}
577579

@@ -602,6 +604,7 @@ ChunkedBatch chunks the given `objects` list in subset of 1000 elements max in o
602604
*/
603605
func (c *APIClient) ChunkedBatch(indexName string, objects []map[string]any, action Action, opts ...ChunkedBatchOption) ([]BatchResponse, error) {
604606
conf := config{
607+
headerParams: map[string]string{},
605608
waitForTasks: false,
606609
batchSize: 1000,
607610
}
@@ -653,6 +656,7 @@ func (c *APIClient) ReplaceAllObjects(indexName string, objects []map[string]any
653656
tmpIndexName := fmt.Sprintf("%s_tmp_%d", indexName, time.Now().UnixNano())
654657
655658
conf := config{
659+
headerParams: map[string]string{},
656660
scopes: []ScopeType{SCOPE_TYPE_SETTINGS, SCOPE_TYPE_RULES, SCOPE_TYPE_SYNONYMS},
657661
}
658662

0 commit comments

Comments
 (0)