forked from influxdata/flux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compiler.go
36 lines (30 loc) · 1004 Bytes
/
compiler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package flux
import (
"context"
"fmt"
"github.com/influxdata/flux/memory"
)
// Compiler produces a specification for the query.
type Compiler interface {
// Compile produces a specification for the query.
Compile(ctx context.Context) (Program, error)
CompilerType() CompilerType
}
// CompilerType is the name of a query compiler.
type CompilerType string
type CreateCompiler func() Compiler
type CompilerMappings map[CompilerType]CreateCompiler
func (m CompilerMappings) Add(t CompilerType, c CreateCompiler) error {
if _, ok := m[t]; ok {
return fmt.Errorf("duplicate compiler mapping for %q", t)
}
m[t] = c
return nil
}
// Program defines a Flux script which has been compiled.
type Program interface {
// Start begins execution of the program and returns immediately.
// As results are produced they arrive on the channel.
// The program is finished once the result channel is closed and all results have been consumed.
Start(context.Context, *memory.Allocator) (Query, error)
}