Skip to content

Commit

Permalink
Refactor the library (#557)
Browse files Browse the repository at this point in the history
* docs: add package documentation

* fix: refactor fasthttp client to http client

* chore: add general errors

* feat: add option pattern for make optional client

* docs: update documentation of types

* chore: add example test for function New and Connect

* docs: update readme for new meilisearch

* chore: add helper function with test

* feat: add service manager to manage index, key, task and other operation

* feat: add index manager to manage index and search

* fix: update module version to 1.17 for fix issue testify

* fix: update go module

* fix: change testify version to stable and support go 1.16

* docs: update example documentation

* chore: update many for coverage

* fix: improved coverage test of client

* fix: client test except on pool

* fix: change old client example to new

* fix: add test for RawType to improve coverage

* fix: add update documents test for improve coverage

* fix: improved coverage test of client with some scenarios

---------

Co-authored-by: Javad <ja7ad@live.com>
Co-authored-by: meili-bors[bot] <89034592+meili-bors[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 14, 2024
1 parent 6b5e6fb commit ad4b0b2
Show file tree
Hide file tree
Showing 34 changed files with 6,928 additions and 7,206 deletions.
51 changes: 11 additions & 40 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -515,10 +515,7 @@ add_movies_json_1: |-
client.Index("movies").AddDocuments(&movies)
landing_getting_started_1: |-
client := meilisearch.NewClient(meilisearch.ClientConfig{
Host: "http://localhost:7700",
APIKey: "masterKey",
})
client := meilisearch.New("http://localhost:7700", meilisearch.WithAPIKey("masterKey"))
documents := []map[string]interface{}{
{ "id": 1, "title": "Carol" },
Expand Down Expand Up @@ -548,10 +545,7 @@ getting_started_add_documents_md: |-
)
func main() {
client := meilisearch.NewClient(meilisearch.ClientConfig{
Host: "http://localhost:7700",
APIKey: aSampleMasterKey,
})
client := meilisearch.New("http://localhost:7700", meilisearch.WithAPIKey("masterKey"))
jsonFile, _ := os.Open("movies.json")
defer jsonFile.Close()
Expand All @@ -576,9 +570,7 @@ getting_started_search_md: |-
[About this SDK](https://github.com/meilisearch/meilisearch-go/)
getting_started_add_meteorites: |-
client := meilisearch.NewClient(meilisearch.ClientConfig{
Host: "http://localhost:7700",
})
client := meilisearch.New("http://localhost:7700")
jsonFile, _ := os.Open("meteorites.json")
defer jsonFile.Close()
Expand Down Expand Up @@ -791,25 +783,16 @@ primary_field_guide_add_document_primary_key: |-
primary_field_guide_update_document_primary_key: |-
client.Index("books").UpdateIndex("title")
security_guide_search_key_1: |-
client := meilisearch.NewClient(meilisearch.ClientConfig{
Host: "http://localhost:7700",
APIKey: "apiKey",
})
client := meilisearch.New("http://localhost:7700", meilisearch.WithAPIKey("masterKey"))
client.Index("patient_medical_records").Search();
security_guide_update_key_1: |-
client := meilisearch.NewClient(meilisearch.ClientConfig{
Host: "http://localhost:7700",
APIKey: "masterKey",
})
client := meilisearch.New("http://localhost:7700", meilisearch.WithAPIKey("masterKey"))
client.UpdateKey("74c9c733-3368-4738-bbe5-1d18a5fecb37", &meilisearch.Key{
Indexes: []string{"doctors"},
})
security_guide_create_key_1: |-
client := meilisearch.NewClient(meilisearch.ClientConfig{
Host: "http://localhost:7700",
APIKey: "masterKey",
})
client := meilisearch.New("http://localhost:7700", meilisearch.WithAPIKey("masterKey"))
client.CreateKey(&meilisearch.Key{
Description: "Search patient records key",
Expand All @@ -818,22 +801,13 @@ security_guide_create_key_1: |-
ExpiresAt: time.Date(2042, time.April, 02, 0, 42, 42, 0, time.UTC),
})
security_guide_list_keys_1: |-
client := meilisearch.NewClient(meilisearch.ClientConfig{
Host: "http://localhost:7700",
APIKey: "masterKey",
})
client := meilisearch.New("http://localhost:7700", meilisearch.WithAPIKey("masterKey"))
client.GetKeys(nil);
security_guide_delete_key_1: |-
client := meilisearch.NewClient(meilisearch.ClientConfig{
Host: "http://localhost:7700",
APIKey: "masterKey",
})
client := meilisearch.New("http://localhost:7700", meilisearch.WithAPIKey("masterKey"))
client.DeleteKey("74c9c733-3368-4738-bbe5-1d18a5fecb37");
authorization_header_1: |-
client := meilisearch.NewClient(meilisearch.ClientConfig{
Host: "http://localhost:7700",
APIKey: "masterKey",
})
client := meilisearch.New("http://localhost:7700", meilisearch.WithAPIKey("masterKey"))
client.GetKeys(nil);
tenant_token_guide_generate_sdk_1: |-
searchRules := map[string]interface{}{
Expand All @@ -848,11 +822,8 @@ tenant_token_guide_generate_sdk_1: |-
token, err := client.GenerateTenantToken(searchRules, options);
tenant_token_guide_search_sdk_1: |-
frontEndClient := meilisearch.NewClient(meilisearch.ClientConfig{
Host: "http://localhost:7700",
APIKey: token,
})
frontEndClient.Index("patient_medical_records").Search("blood test", &meilisearch.SearchRequest{});
client := meilisearch.New("http://localhost:7700", meilisearch.WithAPIKey("masterKey"))
client.Index("patient_medical_records").Search("blood test", &meilisearch.SearchRequest{});
synonyms_guide_1: |-
synonyms := map[string][]string{
"great": []string{"fantastic"},
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,8 @@ import (
)

func main() {
client := meilisearch.NewClient(meilisearch.ClientConfig{
Host: "http://127.0.0.1:7700",
APIKey: "masterKey",
})
client := meilisearch.New("http://localhost:7700", meilisearch.WithAPIKey("foobar"))

// An index is where the documents are stored.
index := client.Index("movies")

Expand Down
Loading

0 comments on commit ad4b0b2

Please sign in to comment.