algolia / algolia/algoliasearch-client-go

Index.Exists doesn't accept options (and so context)

Open
#710 2 comments 0 reactions 0 assignees View on GitHub
Breaking change
Dominant language
Go
Stars
200
Forks
60
PR merge metrics
No merged PRs in 30d

Description

- Algolia Client Version: 3.26.1

### Description

Currently the function [index.Exists](https://github.com/algolia/algoliasearch-client-go/blob/15d0de75e06af571cff6db73e340f000bf5d278f/algolia/search/index.go#L107) doesn't accept options like other functions.

We use `opts` to pass the current context. With a custom `Requester` (`http.client`) it's allow us to do tracing.
Without opts we can trace correctly this `Exists` function 😞

Is it possible to add `opts` on `Exists` function, like this ?
```go
func (i *Index) Exists(opts ...interface{}) (bool, error) {
_, err := i.GetSettings(opts)
if err == nil {
return true, nil
}
if _, ok := errs.IsAlgoliaErrWithCode(err, http.StatusNotFound); ok {
return false, nil
}
return false, err
}
```

I can create a PR to fix this 👍🏻

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in algolia/search/index.go at Index.Exists and compare its signature with other functions that accept options. Check how Exists delegates to GetSettings and how opts reach the custom Requester; done means Exists accepts and forwards options while preserving its existing true, false, and error behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.