Skip to content

Commit

Permalink
fix(go): explicit usage of browse helpers (#3417)
Browse files Browse the repository at this point in the history
  • Loading branch information
millotp authored Jul 25, 2024
1 parent e0459e3 commit ed9e145
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 88 deletions.
4 changes: 2 additions & 2 deletions playground/go/ingestion.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func testIngestion(appID, apiKey string) int {

printResponse(createAuthenticationResponse)

listAuthenticationsResponse, err := ingestionClient.GetAuthentications(
ingestionClient.NewApiGetAuthenticationsRequest().WithItemsPerPage(2),
listAuthenticationsResponse, err := ingestionClient.ListAuthentications(
ingestionClient.NewApiListAuthenticationsRequest().WithItemsPerPage(2),
)
if err != nil {
fmt.Printf("request error with GetAuthentications: %v\n", err)
Expand Down
14 changes: 10 additions & 4 deletions playground/go/search.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"context"
"fmt"

"github.com/algolia/algoliasearch-client-go/v4/algolia/search"
)
Expand All @@ -13,9 +13,15 @@ func testSearch(appID, apiKey string) int {
panic(err)
}

res, err := searchClient.WaitForApiKey("test", search.API_KEY_OPERATION_ADD, search.WithContext(context.Background()), search.WithMaxRetries(4))
print(res)
print(err.Error())
err = searchClient.BrowseObjects("test-flag", *search.NewEmptyBrowseParamsObject(), search.WithAggregator(func(res any, err error) {
if err != nil {
panic(err)
}
fmt.Println(len(res.(*search.BrowseResponse).Hits))
}))
if err != nil {
panic(err)
}

/*
response, err := searchClient.AddOrUpdateObject(
Expand Down
7 changes: 0 additions & 7 deletions templates/go/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ type config struct {
maxRetries int
timeout func(int) time.Duration
aggregator func(any, error)
iterableError *IterableError

// -- WaitForApiKey options
apiKey *ApiKey
Expand Down Expand Up @@ -187,12 +186,6 @@ func WithAggregator(aggregator func(any, error)) iterableOption {
})
}

func WithIterableError(iterableError *IterableError) iterableOption {
return iterableOption(func(c *config) {
c.iterableError = iterableError
})
}

// --------- WaitForKey options ---------.

type WaitForApiKeyOption interface {
Expand Down
Loading

0 comments on commit ed9e145

Please sign in to comment.