diff --git a/content/index.html b/content/index.html index b993b8f..45ebf3b 100644 --- a/content/index.html +++ b/content/index.html @@ -13,7 +13,7 @@ .whoarewe-inner { margin-right: 25%; margin-left: 25%; - margin-bottom: 5%; + margin-bottom: 2%; } .playtechnique { @@ -32,9 +32,6 @@ margin-left: 25%; } - footer { - font-size: 0.9em; - } @@ -58,17 +55,10 @@
playtechnique -
-
-

I believe learning how to play as an adult is a skill.

-

Developing technique makes skills more rewarding, more enjoyable, more fun.

-

I want to develop my skills, so that they're more fun, more playful.

-

The more I develop play technique, the more fun it is to play.

-
- - {{ .AndrewTableOfContents }} +
+ This website is served with Andrew, a web + server I put together to serve web pages from flat files on the file system. +

+

+ Andrew has an RSS feed generator, a sitemap generator, automatic table of contents generation. Try it out, you + may like it. +

+
+
- - \ No newline at end of file + \ No newline at end of file diff --git a/content/projects/gsync/create-a-trigger-table-and-watch-grafana-save-changes.html b/content/projects/gsync/create-a-trigger-table-and-watch-grafana-save-changes.html new file mode 100644 index 0000000..ee24f14 --- /dev/null +++ b/content/projects/gsync/create-a-trigger-table-and-watch-grafana-save-changes.html @@ -0,0 +1,119 @@ + + + + + Create A Trigger Table And Watch Grafana Save Changes + + + + + + + +
+
+
+

Create A Trigger Table And Watch Grafana Save Changes

+
+

+ Time to do some serious business now. Let's actually watch some + changes in Grafana and respond to them. +

+

+ The simplest response I can think of is logging to stdout some nice + text. +

+

+ First, I'll make a trigger table watching the dashboards table, then + figure out what happens afterwards. +

+
+ +
+

The Trigger Table

+ +

First let's grab a database real quick.

+

+; docker run -v $(pwd):/mnt/ -it --entrypoint bash gwyn-baseline-adds-data-source:1
+$ cp /var/lib/grafana/grafana.db /mnt/
+ctrl+d
+
+

Ta da!

+ + + +

Now a quick trigger table:

+

+-- Ensure the _gsync_dashboard_tracker table has the necessary columns
+CREATE TABLE IF NOT EXISTS _gsync_dashboard_tracker (
+    _rowid INTEGER,
+    id INTEGER,
+    title TEXT,  -- updated from 'input' to 'title'
+    _version INTEGER,
+    _updated INTEGER
+);
+
+-- Create the trigger to track inserts in the dashboard table
+
+CREATE TRIGGER IF NOT EXISTS gsync_dashboard_insert_tracker
+AFTER INSERT OR UPDATE ON dashboard
+BEGIN
+    INSERT INTO _gsync_dashboard_tracker (_rowid, id, title, _version, _updated)
+    VALUES (new.rowid, new.id, new.title, 1, CAST(strftime('%s', 'now') AS INTEGER));
+END; 
+
+

+ This triggers correctly; I get entries in _gsync_dashboard_tracker + when inserts or updates happen. Great. What should actually happen, + though? +

+
+
+

The Wrong Approach

+

+ This exploration has been pretty interesting and neat and all, but I'm + starting to reach the conclusion it's the wrong approach. +

+

+ What it accomplishes is updating a table whenever a different table is + updated. The reason is that the design I thought I wanted is to have a + callback in a go process that responds to changes in this table. +

+

+ I hadn't considered a simple problem: what if the daemon dies? Does it + try to register another callback it can respond to? The limitation of + go callbacks for sqlite databases is that you can't have the callback + registered outside of the current database connection. If the current + db connection didn't create the callback trigger, I don't think it can + register a callback to automatically respond to the trigger changes; + it'd need to be monitoring the table actively. If that's the case, why + do I need the trigger table in the first place? +

+

+ I have an idea towards a simpler design: a simple daemon that dumps + the contents of the dashboard table to json files. I can monitor the + json files for changes using fsnotify. +

+

+ I learned a good load about using sqlite so far in this project, + though. I never had confidence with it, but now I've got a handle on + it, so that's got to be worth something, right? +

+
+
+
+ diff --git a/content/projects/grafanasink/how-grafanas-sqlite-database-sees-a-new-dashboard-and-panel.html b/content/projects/gsync/how-grafanas-sqlite-database-sees-a-new-dashboard-and-panel.html similarity index 100% rename from content/projects/grafanasink/how-grafanas-sqlite-database-sees-a-new-dashboard-and-panel.html rename to content/projects/gsync/how-grafanas-sqlite-database-sees-a-new-dashboard-and-panel.html diff --git a/content/projects/grafanasink/tracking-sqlite-changes.html b/content/projects/gsync/tracking-sqlite-changes.html similarity index 100% rename from content/projects/grafanasink/tracking-sqlite-changes.html rename to content/projects/gsync/tracking-sqlite-changes.html diff --git a/content/projects/grafanasink/writing-a-daemon-in-golang.html b/content/projects/gsync/writing-a-daemon-in-golang.html similarity index 100% rename from content/projects/grafanasink/writing-a-daemon-in-golang.html rename to content/projects/gsync/writing-a-daemon-in-golang.html