-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The final push to make everything that goes to the db be an event to the event_log. This commit creates the `CreateTest` event, which contains the agenda and the deployment. There is now also an `test_info` view that will contain the agenda and deployment as columns (the data is still in json). This means that we no longer use the `agenda`, `deployment` or `test` tables. Noticeable renamings: * in deployment we now call the reactors `reactor` instead of `component`.
- Loading branch information
1 parent
b63512d
commit d224bf3
Showing
11 changed files
with
200 additions
and
163 deletions.
There are no files selected for viewing
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,20 @@ | ||
-- +migrate Up | ||
CREATE VIEW IF NOT EXISTS test_info AS | ||
SELECT | ||
json_extract(meta, '$.test-id') as test_id, | ||
json_extract(data, '$.agenda') as agenda, | ||
json_extract(data, '$.deployment') as deployment, | ||
at as created_time | ||
FROM event_log | ||
WHERE event like 'CreateTest'; | ||
|
||
DROP TABLE IF EXISTS deployment; | ||
DROP TABLE IF EXISTS agenda; | ||
DROP TABLE IF EXISTS test; | ||
|
||
-- +migrate Down | ||
DROP VIEW IF EXISTS test_info; | ||
|
||
CREATE TABLE IF NOT EXISTS test (rowid INTEGER PRIMARY KEY) WITHOUT ROWID; | ||
CREATE TABLE IF NOT EXISTS agenda (rowid INTEGER PRIMARY KEY) WITHOUT ROWID; | ||
CREATE TABLE IF NOT EXISTS deployment (rowid INTEGER PRIMARY KEY) WITHOUT ROWID; |
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 |
---|---|---|
|
@@ -4,6 +4,7 @@ go_library( | |
name = "lib", | ||
srcs = [ | ||
"checker.go", | ||
"event.go", | ||
"generator.go", | ||
"ldfi.go", | ||
"lib.go", | ||
|
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,30 @@ | ||
package lib | ||
|
||
import ( | ||
"database/sql" | ||
"encoding/json" | ||
) | ||
|
||
func EmitEvent(db *sql.DB, event string, meta interface{}, data interface{}) { | ||
metaBlob, err := json.Marshal(meta) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
dataBlob, err := json.Marshal(data) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
stmt, err := db.Prepare(`INSERT INTO event_log(event, meta, data) VALUES(?,?,?)`) | ||
if err != nil { | ||
panic(err) | ||
} | ||
defer stmt.Close() | ||
|
||
_, err = stmt.Exec(event, metaBlob, dataBlob) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
} |
Oops, something went wrong.