Merge pull request #468 from influxdata/jl-controller-set-now-time

controller sets Now time before enqueuing a query
pull/10616/head
jlapacik 2018-07-26 10:45:17 -07:00 committed by GitHub
commit 3c7d438519
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View File

@ -81,12 +81,19 @@ func (c *Controller) QueryWithCompile(ctx context.Context, orgID platform.ID, qu
return q, err
}
// Query submits a query for execution returning immediately.
// The spec must not be modified while the query is still active.
// Done must be called on any returned Query objects.
// Query submits a query for execution returning immediately. Once a query
// is submitted, that is once a query is enqueued, the query spec must not
// be modified. Done must be called on any returned Query objects.
func (c *Controller) Query(ctx context.Context, orgID platform.ID, qSpec *query.Spec) (query.Query, error) {
q := c.createQuery(ctx, orgID)
q.spec = *qSpec
// Incoming query spec may have been produced by an entity other than the
// Flux interpreter, so we must set the default Now time if not already set.
if q.spec.Now.IsZero() {
q.spec.Now = q.now
}
err := c.enqueueQuery(q)
return q, err
}

View File

@ -45,6 +45,9 @@ func (q *Spec) Walk(f func(o *Operation) error) error {
// Validate ensures the query is a valid DAG.
func (q *Spec) Validate() error {
if q.Now.IsZero() {
return errors.New("now time must be set")
}
return q.prepare()
}