~gabe/mortar unlisted

823512abdde5bb24a44683e113cfaa5093493dcf — Gabe Fierro 1 year, 6 months ago 1b8a75c
reporting errors, supporting empty dataframe requests (only views)
3 files changed, 26 insertions(+), 3 deletions(-)

M stages/frontend.go
M stages/request.go
M stages/timeseries.go
M stages/frontend.go => stages/frontend.go +2 -1
@@ 228,7 228,8 @@ func (stage *ApiFrontendBasicStage) Fetch(request *mortarpb.FetchRequest, client
				if resp == nil {
					// if this is nil then we are done, but there's no error (yet)
					break sendloop
				} else if err = client.Send(resp); err != nil {
				}
				if err = client.Send(resp); err != nil {
					// we have an error on sending, so we tear it all down
					log.Error(errors.Wrap(err, "Error on sending"))
					finishResponse(resp)

M stages/request.go => stages/request.go +20 -2
@@ 46,8 46,26 @@ func NewFetchRequest(ctx context.Context, fetch *mortarpb.FetchRequest) *Request
}

func (request *Request) addError(err error) {
	if request.err == nil {
		request.err = err
	if request.err != nil {
		return
	}
	request.err = err
	if request.fetch_responses != nil {
		request.fetch_responses <- &mortarpb.FetchResponse{
			Error: err.Error(),
		}
	} else if request.qualify_responses != nil {
		request.qualify_responses <- &mortarpb.QualifyResponse{
			Error: err.Error(),
		}
	}
}

func (request *Request) finish() {
	if request.fetch_responses != nil {
		request.fetch_responses <- nil
	} else if request.qualify_responses != nil {
		request.qualify_responses <- nil
	}
}


M stages/timeseries.go => stages/timeseries.go +4 -0
@@ 59,9 59,13 @@ func NewTimeseriesQueryStage(cfg *TimeseriesStageConfig) (*TimeseriesQueryStage,
				case req := <-input:
					if len(req.fetch_request.Sites) > 0 && len(req.fetch_request.DataFrames) > 0 {
						if err := stage.processQuery(req); err != nil {
							req.addError(err)
							log.Println(err)
						}
					} else {
						req.finish()
					}

					//stage.output <- req
				case <-stage.ctx.Done():
					// case that breaks the stage and releases resources