Skip to content

Commit ae41835

Browse files
committed
added a shared util to determine if a function is running in batch mode
1 parent 7012605 commit ae41835

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

utils/batch_mode.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2023-2025 Princess Beef Heavy Industries, LLC / Dave Shanley
2+
// https://pb33f.io
3+
4+
package utils
5+
6+
// IsBatchMode checks if batch mode is enabled in function options.
7+
// When batch mode is enabled, all matched nodes are passed to the function
8+
// at once instead of invoking the function once per node.
9+
func IsBatchMode(options interface{}) bool {
10+
if m, ok := options.(map[string]interface{}); ok {
11+
if batch, exists := m["batch"]; exists {
12+
if b, ok := batch.(bool); ok {
13+
return b
14+
}
15+
}
16+
}
17+
return false
18+
}

0 commit comments

Comments
 (0)