-
Notifications
You must be signed in to change notification settings - Fork 154
/
executor.go
38 lines (30 loc) · 1.01 KB
/
executor.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
37
38
package mock
import (
"context"
"github.com/influxdata/flux"
"github.com/influxdata/flux/execute"
"github.com/influxdata/flux/memory"
"github.com/influxdata/flux/plan"
)
var _ execute.Executor = (*Executor)(nil)
var NoMetadata <-chan flux.Metadata
// Executor is a mock implementation of an execute.Executor.
type Executor struct {
ExecuteFn func(ctx context.Context, p *plan.Spec, a *memory.Allocator) (map[string]flux.Result, <-chan flux.Metadata, error)
}
// NewExecutor returns a mock Executor where its methods will return zero values.
func NewExecutor() *Executor {
return &Executor{
ExecuteFn: func(context.Context, *plan.Spec, *memory.Allocator) (map[string]flux.Result, <-chan flux.Metadata, error) {
return nil, NoMetadata, nil
},
}
}
func (e *Executor) Execute(ctx context.Context, p *plan.Spec, a *memory.Allocator) (map[string]flux.Result, <-chan flux.Metadata, error) {
return e.ExecuteFn(ctx, p, a)
}
func init() {
noMetaCh := make(chan flux.Metadata)
close(noMetaCh)
NoMetadata = noMetaCh
}