Skip to content

Commit 3b34349

Browse files
committed
fix go again
1 parent 6291847 commit 3b34349

File tree

13 files changed

+414
-311
lines changed

13 files changed

+414
-311
lines changed

clients/algoliasearch-client-go/algolia/utils/options.go

Lines changed: 0 additions & 157 deletions
This file was deleted.

clients/algoliasearch-client-go/algolia/utils/utils.go

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import (
88
"reflect"
99
"strings"
1010
"time"
11-
12-
"github.com/algolia/algoliasearch-client-go/v4/algolia/errs"
1311
)
1412

1513
// ToPtr is a helper routine that returns a pointer to the given value.
@@ -68,60 +66,6 @@ func IsNilOrEmpty(i any) bool {
6866
}
6967
}
7068

71-
type IterableError struct {
72-
Validate func(any, error) bool
73-
Message func(any, error) string
74-
}
75-
76-
func CreateIterable[T any](execute func(*T, error) (*T, error), validate func(*T, error) bool, opts ...IterableOption) (*T, error) {
77-
options := Options{
78-
MaxRetries: 50,
79-
Timeout: func(_ int) time.Duration {
80-
return 1 * time.Second
81-
},
82-
}
83-
84-
for _, opt := range opts {
85-
opt.Apply(&options)
86-
}
87-
88-
var executor func(*T, error) (*T, error)
89-
90-
retryCount := 0
91-
92-
executor = func(previousResponse *T, previousError error) (*T, error) {
93-
response, responseErr := execute(previousResponse, previousError)
94-
95-
retryCount++
96-
97-
if options.Aggregator != nil {
98-
options.Aggregator(response, responseErr)
99-
}
100-
101-
if validate(response, responseErr) {
102-
return response, nil
103-
}
104-
105-
if retryCount >= options.MaxRetries {
106-
return nil, errs.NewWaitError(fmt.Sprintf("The maximum number of retries exceeded. (%d/%d)", retryCount, options.MaxRetries))
107-
}
108-
109-
if options.IterableError != nil && options.IterableError.Validate(response, responseErr) {
110-
if options.IterableError.Message != nil {
111-
return nil, errs.NewWaitError(options.IterableError.Message(response, responseErr))
112-
}
113-
114-
return nil, errs.NewWaitError("an error occurred")
115-
}
116-
117-
time.Sleep(options.Timeout(retryCount))
118-
119-
return executor(response, responseErr)
120-
}
121-
122-
return executor(nil, nil)
123-
}
124-
12569
// QueryParameterToString convert any query parameters to string.
12670
func QueryParameterToString(obj any) string {
12771
return strings.ReplaceAll(url.QueryEscape(ParameterToString(obj)), "+", "%20")

generators/src/main/java/com/algolia/codegen/cts/tests/ParametersWithDataType.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,12 @@ private Map<String, Object> traverseParams(
105105
boolean isCodegenModel = spec instanceof CodegenModel;
106106

107107
Map<String, Object> testOutput = createDefaultOutput();
108+
boolean isRequired = false;
108109

109110
if (spec instanceof CodegenParameter parameter) {
110-
testOutput.put("required", parameter.required);
111+
isRequired = parameter.required;
111112
} else if (spec instanceof CodegenProperty property) {
112-
testOutput.put("required", property.required);
113+
isRequired = property.required;
113114
}
114115

115116
if (!isCodegenModel) {
@@ -130,6 +131,8 @@ private Map<String, Object> traverseParams(
130131
testOutput.put("isKeyAllUpperCase", StringUtils.isAllUpperCase(finalParamName));
131132
testOutput.put("parentSuffix", suffix - 1);
132133
testOutput.put("useAnonymousKey", !finalParamName.matches("(.*)_[0-9]$") && suffix != 0);
134+
testOutput.put("required", isRequired);
135+
testOutput.put("goFunctionalParam", !isRequired && suffix == 0);
133136
testOutput.put("suffix", suffix);
134137
testOutput.put("parent", parent);
135138
testOutput.put("isRoot", "".equals(parent));

playground/go/personalization.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"time"
77

88
"github.com/algolia/algoliasearch-client-go/v4/algolia/personalization"
9-
"github.com/algolia/algoliasearch-client-go/v4/algolia/utils"
109
)
1110

1211
func testPersonalization(appID, apiKey string) int {
@@ -20,7 +19,7 @@ func testPersonalization(appID, apiKey string) int {
2019
// it will fail expectedly because of the very short timeout to showcase the context usage.
2120
deleteUserProfileResponse, err := personalizationClient.DeleteUserProfile(
2221
personalizationClient.NewApiDeleteUserProfileRequest("userToken"),
23-
utils.WithContext(ctx),
22+
personalization.WithContext(ctx),
2423
)
2524
if err != nil {
2625
fmt.Printf("request error with DeleteUserProfile: %v\n", err)

playground/go/search.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55

66
"github.com/algolia/algoliasearch-client-go/v4/algolia/search"
7-
"github.com/algolia/algoliasearch-client-go/v4/algolia/utils"
87
)
98

109
func testSearch(appID, apiKey string) int {
@@ -14,7 +13,7 @@ func testSearch(appID, apiKey string) int {
1413
panic(err)
1514
}
1615

17-
res, err := searchClient.WaitForApiKey(search.API_KEY_OPERATION_ADD, "test", &search.ApiKey{}, utils.WithContext(context.Background()), utils.WithMaxRetries(4))
16+
res, err := searchClient.WaitForApiKey("test", search.API_KEY_OPERATION_ADD, &search.ApiKey{}, search.WithContext(context.Background()), search.WithMaxRetries(4))
1817
print(res)
1918
print(err.Error())
2019

0 commit comments

Comments
 (0)