github.com/influxdata/influxdb/v2@v2.7.6/influxql/query/execution_context.go (about) 1 package query 2 3 import ( 4 "context" 5 6 iql "github.com/influxdata/influxdb/v2/influxql" 7 ) 8 9 // ExecutionContext contains state that the query is currently executing with. 10 type ExecutionContext struct { 11 // The statement ID of the executing query. 12 statementID int 13 14 // Output channel where results and errors should be sent. 15 Results chan *Result 16 17 // StatisticsGatherer gathers metrics about the execution of a query. 18 StatisticsGatherer *iql.StatisticsGatherer 19 20 // Options used to start this query. 21 ExecutionOptions 22 } 23 24 // Send sends a Result to the Results channel and will exit if the query has 25 // been interrupted or aborted. 26 func (ectx *ExecutionContext) Send(ctx context.Context, result *Result) error { 27 result.StatementID = ectx.statementID 28 select { 29 case <-ctx.Done(): 30 return ctx.Err() 31 case ectx.Results <- result: 32 } 33 return nil 34 }