-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathzero-cost-condition.conf
61 lines (47 loc) · 1.31 KB
/
zero-cost-condition.conf
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
@version: 3.25
#
# It is possible to build a new plugin based on configuration only with the block syntaxt.
# Despite the block could have parameters, those values are always just implaced, and ther is
# no way to check their value and do operation A or operation B.
# Well at least not during config parsing time, with runtime penalty of course using the
# if { } else {} construct that is possible.
#
block parser parse(name()) {
channel {
rewrite { set("parse-`name`" value(".parser")); };
};
};
# With if {} else {} runtime condition.
# There is an if-parser.png showing the graph created from this version.
block parser if-based-parser( do-parse-a(yes) )
{
channel {
if ("`do-parse-a`" == "yes") {
parse(name("A"));
}
else {
parse(name("B"));
};
};
};
# Without runtime penalty.
# There is an ifless.png showing the graph created from this version.
block parser parse-do-parse-a-yes()
{
parse(name("A"));
};
block parser parse-do-parse-a-no()
{
# <SKIP,S> = S
channel {};
};
block parser ifless-parser( do-parse-a(yes) )
{
parse-do-parse-a-`do-parse-a`();
};
log {
source { example-msg-generator(num(1)); };
parser { if-based-parser( do-parse-a(no) ); };
parser { ifless-parser( do-parse-a(no) ); };
destination { file("/dev/stdout" template("parser: ${.parser}\n")); };
};