-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/worklog: add initial generalised database wiring
Deprecate the database_dir configuration, to be removed in a month.
- Loading branch information
Showing
6 changed files
with
288 additions
and
12 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
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 |
---|---|---|
@@ -0,0 +1,143 @@ | ||
# The build of worklog takes a fair while due to the size of the dependency | ||
# tree, the size of some of the individual dependencies and the absence of | ||
# cachine when building within a test script. | ||
[short] stop 'Skipping long test.' | ||
|
||
env HOME=${WORK} | ||
|
||
[linux] env XDG_CONFIG_HOME=${HOME}/.config | ||
[linux] env XDG_RUNTIME_DIR=${HOME}/runtime | ||
[linux] mkdir ${XDG_CONFIG_HOME}/dex | ||
[linux] mkdir ${XDG_RUNTIME_DIR} | ||
[linux] mv config.toml ${HOME}/.config/dex/config.toml | ||
|
||
[darwin] mkdir ${HOME}'/Library/Application Support/dex' | ||
[darwin] mv config.toml ${HOME}'/Library/Application Support/dex/config.toml' | ||
|
||
env GOBIN=${WORK}/bin | ||
env PATH=${GOBIN}:${PATH} | ||
cd ${PKG_ROOT} | ||
go install ./cmd/worklog | ||
cd ${WORK} | ||
|
||
dex -log debug -lines &dex& | ||
sleep 1s | ||
|
||
POST dump.json http://localhost:7979/load/?replace=true | ||
|
||
GET -json http://localhost:7979/dump/ | ||
cmp stdout want.json | ||
|
||
GET http://localhost:7979/query?sql=select+count(*)+as+event_count+from+events | ||
cmp stdout want_event_count.json | ||
|
||
-- config.toml -- | ||
[kernel] | ||
device = [] | ||
network = "tcp" | ||
|
||
[module.worklog] | ||
path = "worklog" | ||
log_mode = "log" | ||
log_level = "debug" | ||
log_add_source = true | ||
|
||
[module.worklog.options] | ||
database_dir = "worklog" | ||
hostname = "localhost" | ||
[module.worklog.options.web] | ||
addr = "localhost:7979" | ||
can_modify = true | ||
|
||
-- dump.json -- | ||
{ | ||
"buckets": [ | ||
{ | ||
"id": "afk_localhost", | ||
"name": "afk-watcher", | ||
"type": "afkstatus", | ||
"client": "worklog", | ||
"hostname": "localhost", | ||
"created": "2023-12-04T17:21:27.424207553+10:30", | ||
"events": [ | ||
{ | ||
"bucket": "afk", | ||
"id": 2, | ||
"start": "2023-12-04T17:21:28.270750821+10:30", | ||
"end": "2023-12-04T17:21:28.270750821+10:30", | ||
"data": { | ||
"afk": false, | ||
"locked": false | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "window_localhost", | ||
"name": "window-watcher", | ||
"type": "currentwindow", | ||
"client": "worklog", | ||
"hostname": "localhost", | ||
"created": "2023-12-04T17:21:27.428793055+10:30", | ||
"events": [ | ||
{ | ||
"bucket": "window", | ||
"id": 1, | ||
"start": "2023-12-04T17:21:28.270750821+10:30", | ||
"end": "2023-12-04T17:21:28.270750821+10:30", | ||
"data": { | ||
"app": "Gnome-terminal", | ||
"title": "Terminal" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
-- want.json -- | ||
{ | ||
"buckets": [ | ||
{ | ||
"id": "afk_localhost", | ||
"name": "afk-watcher", | ||
"type": "afkstatus", | ||
"client": "worklog", | ||
"hostname": "localhost", | ||
"created": "2023-12-04T17:21:27.424207553+10:30", | ||
"events": [ | ||
{ | ||
"bucket": "afk", | ||
"id": 1, | ||
"start": "2023-12-04T17:21:28.270750821+10:30", | ||
"end": "2023-12-04T17:21:28.270750821+10:30", | ||
"data": { | ||
"afk": false, | ||
"locked": false | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "window_localhost", | ||
"name": "window-watcher", | ||
"type": "currentwindow", | ||
"client": "worklog", | ||
"hostname": "localhost", | ||
"created": "2023-12-04T17:21:27.428793055+10:30", | ||
"events": [ | ||
{ | ||
"bucket": "window", | ||
"id": 2, | ||
"start": "2023-12-04T17:21:28.270750821+10:30", | ||
"end": "2023-12-04T17:21:28.270750821+10:30", | ||
"data": { | ||
"app": "Gnome-terminal", | ||
"title": "Terminal" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
-- want_event_count.json -- | ||
[{"event_count":2}] |