Browse Source

doc: Adding docs for sinks

Matthias Ladkau 3 years ago
parent
commit
38e355700c
4 changed files with 60 additions and 19 deletions
  1. 53 12
      ecal.md
  2. 2 2
      interpreter/provider.go
  3. 1 1
      interpreter/rt_general_test.go
  4. 4 4
      interpreter/rt_sink_test.go

File diff suppressed because it is too large
+ 53 - 12
ecal.md


+ 2 - 2
interpreter/provider.go

@@ -10,7 +10,7 @@
 
 // TODO:
 // Document event processing with sinks
-// Context supporting final
+// Context supporting final and exception handling
 // Inline escaping in strings "bla {1+1} bla"
 
 package interpreter
@@ -147,7 +147,7 @@ func NewECALRuntimeProvider(name string, importLocator util.ECALImportLocator, l
 
 		// By default imports are located in the current directory
 
-		importLocator = &util.FileImportLocator{filepath.Dir(os.Args[0])}
+		importLocator = &util.FileImportLocator{Root: filepath.Dir(os.Args[0])}
 	}
 
 	if logger == nil {

+ 1 - 1
interpreter/rt_general_test.go

@@ -37,7 +37,7 @@ func TestGeneralErrorCases(t *testing.T) {
 func TestImporting(t *testing.T) {
 
 	vs := scope.NewScope(scope.GlobalScope)
-	il := &util.MemoryImportLocator{make(map[string]string)}
+	il := &util.MemoryImportLocator{Files: make(map[string]string)}
 
 	il.Files["foo/bar"] = `
 b := 123

+ 4 - 4
interpreter/rt_sink_test.go

@@ -27,7 +27,7 @@ func TestEventProcessing(t *testing.T) {
 My cool rule
 */
 sink rule1
-    kindmatch [ "core.*" ],
+    kindmatch [ "core.*", "foo.*" ],
 	scopematch [ "data.write" ],
 	statematch { "val" : NULL },
 	priority 10,
@@ -44,6 +44,7 @@ My cool rule
   kindmatch
     list
       string: 'core.*'
+      string: 'foo.*'
   scopematch
     list
       string: 'data.write'
@@ -79,7 +80,7 @@ GlobalScope {
 	}
 
 	if res := fmt.Sprint(testprocessor.Rules()["rule1"]); res !=
-		`Rule:rule1 [My cool rule] (Priority:10 Kind:[core.*] Scope:[data.write] StateMatch:{"val":null} Suppress:[rule2])` {
+		`Rule:rule1 [My cool rule] (Priority:10 Kind:[core.* foo.*] Scope:[data.write] StateMatch:{"val":null} Suppress:[rule2])` {
 		t.Error("Unexpected result:", res)
 		return
 	}
@@ -247,7 +248,7 @@ rule2 - Handling request: test.event`[1:] {
 	_, err = UnitTestEval(
 		`
 sink rule1
-    kindmatch [ "test.event" ],
+    kindmatch [ "test.event", "foo.*" ],
     statematch { "a" : null },
 	{
         log("rule1 - Handling request: ", event.kind)
@@ -290,5 +291,4 @@ rule2 - Handling request: test.event`[1:] {
 		t.Error("Unexpected result:", testlogger.String())
 		return
 	}
-
 }