forked from influxdata/kapacitor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pipeline tick to AST helper functions
- Loading branch information
Showing
27 changed files
with
127 additions
and
348 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package tick | ||
|
||
import ( | ||
"sort" | ||
|
||
"github.com/influxdata/kapacitor/pipeline" | ||
"github.com/influxdata/kapacitor/tick/ast" | ||
) | ||
|
||
// KapacitorLoopbackNode converts the KapacitorLoopbackNode pipeline node into the TICKScript AST | ||
type KapacitorLoopbackNode struct { | ||
Function | ||
} | ||
|
||
// NewKapacitorLoopbackNode creates a KapacitorLoopbackNode function builder | ||
func NewKapacitorLoopbackNode(parents []ast.Node) *KapacitorLoopbackNode { | ||
return &KapacitorLoopbackNode{ | ||
Function{ | ||
Parents: parents, | ||
}, | ||
} | ||
} | ||
|
||
// Build creates a KapacitorLoopbackNode ast.Node | ||
func (n *KapacitorLoopbackNode) Build(k *pipeline.KapacitorLoopbackNode) (ast.Node, error) { | ||
n.Pipe("kapacitorLoopback"). | ||
Dot("database", k.Database). | ||
Dot("retentionPolicy", k.RetentionPolicy). | ||
Dot("measurement", k.Measurement) | ||
|
||
var tagKeys []string | ||
for key := range k.Tags { | ||
tagKeys = append(tagKeys, key) | ||
} | ||
sort.Strings(tagKeys) | ||
for _, key := range tagKeys { | ||
n.Dot("tag", key, k.Tags[key]) | ||
} | ||
|
||
return n.prev, n.err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package tick_test | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestKapacitorLoopback(t *testing.T) { | ||
pipe, _, from := StreamFrom() | ||
loop := from.KapacitorLoopback() | ||
loop.Database = "mydb" | ||
loop.RetentionPolicy = "myrp" | ||
loop.Measurement = "meas" | ||
loop.Tag("vocabulary", "volcano") | ||
loop.Tag("season", "winter") | ||
|
||
want := `stream | ||
|from() | ||
|kapacitorLoopback() | ||
.database('mydb') | ||
.retentionPolicy('myrp') | ||
.measurement('meas') | ||
.tag('season', 'winter') | ||
.tag('vocabulary', 'volcano') | ||
` | ||
PipelineTickTestHelper(t, pipe, want) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.