MCPcopy Create free account
hub / github.com/couchbase/cbft / DocCount

Method DocCount

remote.go:137–177  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

135}
136
137func (r *IndexClient) DocCount() (uint64, error) {
138 if r.CountURL == "" {
139 return 0, fmt.Errorf("remote: no CountURL provided")
140 }
141 u, err := UrlWithAuth(r.AuthType(), r.CountURL)
142 if err != nil {
143 return 0, fmt.Errorf("remote: auth for count,"+
144 " countURL: %s, authType: %s, err: %v",
145 r.CountURL, r.AuthType(), err)
146 }
147
148 resp, err := HttpGet(r.httpClient, u)
149 if err != nil {
150 return 0, err
151 }
152 defer resp.Body.Close()
153
154 respBuf, err := ioutil.ReadAll(resp.Body)
155 if err != nil {
156 return 0, fmt.Errorf("remote: count error reading resp.Body,"+
157 " countURL: %s, resp: %#v, err: %v", r.CountURL, resp, err)
158 }
159
160 if resp.StatusCode != 200 {
161 return 0, fmt.Errorf("remote: count got status code: %d,"+
162 " countURL: %s, resp: %#v", resp.StatusCode, r.CountURL, resp)
163 }
164
165 rv := struct {
166 Status string `json:"status"`
167 Count uint64 `json:"count"`
168 }{}
169 err = UnmarshalJSON(respBuf, &rv)
170 if err != nil {
171 return 0, fmt.Errorf("remote: count error parsing respBuf: %s,"+
172 " countURL: %s, resp: %#v, err: %v",
173 respBuf, r.CountURL, resp, err)
174 }
175
176 return rv.Count, nil
177}
178
179func (r *IndexClient) Search(req *bleve.SearchRequest) (
180 *bleve.SearchResult, error) {

Callers 3

TestNegativeIndexClientFunction · 0.95
TestBadURLsIndexClientFunction · 0.95
CountMethod · 0.95

Calls 3

AuthTypeMethod · 0.95
UnmarshalJSONFunction · 0.85
CloseMethod · 0.45

Tested by 2

TestNegativeIndexClientFunction · 0.76
TestBadURLsIndexClientFunction · 0.76