From 37032a7045647d0199326fee064ba5ac78ffadfe Mon Sep 17 00:00:00 2001 From: Tim Bray Date: Sat, 31 Dec 2022 10:11:30 -0800 Subject: [PATCH] kaizen: prepare for v1.0.0 fixes: #144 fixes: #121 fixes: #81 Signed-off-by: Tim Bray --- PATTERNS.md | 24 ++++++++++++------------ README.md | 12 +++++------- cl2_test.go | 4 ++-- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/PATTERNS.md b/PATTERNS.md index c9a2696..5868795 100644 --- a/PATTERNS.md +++ b/PATTERNS.md @@ -1,7 +1,7 @@ # Patterns in Quamina **Patterns** are added to Quamina instances using the -`AddPattern` API. This document specifies the syntax and +`AddPattern` API. This document specifies the syntax and semantics of Patterns. The discussion of JSON constructs in this document uses @@ -18,7 +18,7 @@ Unicode characters. As in JSON, the allowed member values may be strings, numbers, the literals `true`, `false`, and `null`, arrays, -and objects. We refer to values which are neither arrays +and objects. We refer to values which are neither arrays nor objects as **Leaf** values. A **Field** is the combination of a Leaf value and a @@ -27,14 +27,14 @@ that must be traversed to reach it from the Event root. For example, in the Event ```json -{"alpha": {"beta": 1}} +{"alpha": {"beta": 1}} ``` There is only one Field whose Leaf value is `1` and whose Path is `"alpha","beta"`. -Paths omit arrays. So in the Event +Paths omit arrays. So in the Event ```json -{"alpha": [ {"beta": [1, 2]}, {"beta": [3, 4]} ] } +{"alpha": [ {"beta": [1, 2]}, {"beta": [3, 4]} ] } ``` The Path for the Leaf value `1` is still `"alpha","beta"` @@ -53,7 +53,7 @@ value. Thus, the following Pattern would match both JSON events above: ```json -{"alpha": {"beta": [1]}} +{"alpha": {"beta": [1]}} ``` ## Extended Patterns @@ -63,7 +63,7 @@ a single field whose name is called the **Pattern Type**. ### Exists Pattern The Pattern Type of an Exists Pattern is `exists` and its -value **MUST** be `true` or `false`. Here +value **MUST** be `true` or `false`. Here are two Exists Patterns that would match the Events above: ```json {"alpha": {"beta": [ {"exists": true} ]}} @@ -77,7 +77,7 @@ Exists Patterns currently only work on leaf nodes. That is to say, given this event: ```json -{ "a": { "b": 1 } } +{ "a": { "b": 1 } } ``` The following pattern will not match: @@ -98,10 +98,10 @@ Then `"exists": true` does not match but `"exists": false` does. I.e., only the first of the two sample patterns below matches. ```json -{ "a": [ { "exists": false } ] } +{ "a": [ { "exists": false } ] } ``` ```json -{ "a": [ { "exists": true } ] } +{ "a": [ { "exists": true } ] } ``` This makes sense in the context of the leaf-node semantics; there really is no value for the `"a"` field. @@ -111,7 +111,7 @@ really is no value for the `"a"` field. The Pattern Type of an Anything-But Pattern is `anything-but` and its value **MUST** be an array -of strings. It will match a string value which +of strings. It will match a string value which is not equal to any of the strings in the array. If a Field in a Pattern contains an Anything-But Pattern, @@ -144,7 +144,7 @@ the AWS EventBridge service, as documented in As of release 1.0, Quamina supports Exists and Anything-But Patterns, but does not yet support any other -EventBridge patterns. Note that a +EventBridge patterns. Note that a Shellstyle Pattern with a trailing `*` is equivalent to a `prefix` pattern. diff --git a/README.md b/README.md index 8f22e03..c063965 100644 --- a/README.md +++ b/README.md @@ -206,9 +206,8 @@ to improve this.) `WithPatternStorage`: If you provide an argument that supports the `LivePatternStorage` API, Quamina will -use it to -maintain a list of which Patterns have currently been -added but not deleted. This could be useful if you +use it tomaintain a list of which Patterns have currently +been added but not deleted. This could be useful if you wanted to rebuild Quamina instances for sharded processing or after a system failure. ***Note: Not yet implemented.*** @@ -348,10 +347,9 @@ Once the list of fields which might match a Pattern is extracted, the cost of traversing the automaton is at most N, the number of fields left after discarding. -So, adding a new Pattern that only -mentions fields which are already mentioned in previous -Patterns is effectively free i.e. O(1) in terms of run-time -performance. +So, adding a new Pattern that only mentions fields which are +already mentioned in previous Patterns is effectively free +i.e. O(1) in terms of run-time performance. ### Further documentation diff --git a/cl2_test.go b/cl2_test.go index 2522fa5..ada0cfb 100644 --- a/cl2_test.go +++ b/cl2_test.go @@ -28,14 +28,14 @@ func getCL2Lines(t *testing.T) [][]byte { } file, err := os.Open("testdata/citylots2.json.gz") if err != nil { - t.Error("Can't open citlots.jlines.gz: " + err.Error()) + t.Fatal("Can't open citylots2.json.gz: " + err.Error()) } defer func(file *os.File) { _ = file.Close() }(file) zr, err := gzip.NewReader(file) if err != nil { - t.Error("Can't open zip reader: " + err.Error()) + t.Fatal("Can't open zip reader: " + err.Error()) } scanner := bufio.NewScanner(zr)