mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-07 11:27:50 +00:00
Fail entire /schema/details request if one field query fails
This commit is contained in:
parent
2773999190
commit
dc6c92771b
2 changed files with 8 additions and 5 deletions
7
api.go
7
api.go
|
|
@ -997,7 +997,7 @@ func (api *API) Schema(ctx context.Context) []*IndexInfo {
|
|||
|
||||
// SchemaDetails returns information about each index in Pilosa including which
|
||||
// fields they contain, and additional field information such as cardinality
|
||||
func (api *API) SchemaDetails(ctx context.Context) []*IndexInfo {
|
||||
func (api *API) SchemaDetails(ctx context.Context) ([]*IndexInfo, error) {
|
||||
span, _ := tracing.StartSpanFromContext(ctx, "API.Schema")
|
||||
defer span.Finish()
|
||||
schema := api.holder.Schema(false)
|
||||
|
|
@ -1007,8 +1007,7 @@ func (api *API) SchemaDetails(ctx context.Context) []*IndexInfo {
|
|||
req := QueryRequest{Index: index.Name, Query: q}
|
||||
resp, err := api.query(ctx, &req)
|
||||
if err != nil {
|
||||
// TODO ?
|
||||
continue
|
||||
return schema, errors.Wrapf(err, "querying cardinality (%s/%s)", index.Name, field.Name)
|
||||
}
|
||||
if len(resp.Results) == 0 {
|
||||
continue
|
||||
|
|
@ -1018,7 +1017,7 @@ func (api *API) SchemaDetails(ctx context.Context) []*IndexInfo {
|
|||
}
|
||||
}
|
||||
}
|
||||
return schema
|
||||
return schema, nil
|
||||
}
|
||||
|
||||
// ApplySchema takes the given schema and applies it across the
|
||||
|
|
|
|||
|
|
@ -681,7 +681,11 @@ func (h *Handler) handleGetSchemaDetails(w http.ResponseWriter, r *http.Request)
|
|||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
schema := h.api.SchemaDetails(r.Context())
|
||||
schema, err := h.api.SchemaDetails(r.Context())
|
||||
if err != nil {
|
||||
h.logger.Printf("error getting detailed schema: %s", err)
|
||||
return
|
||||
}
|
||||
if err := json.NewEncoder(w).Encode(pilosa.Schema{Indexes: schema}); err != nil {
|
||||
h.logger.Printf("write schema response error: %s", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue