Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hide-logs unless you manually turn them on #1919

Merged
merged 1 commit into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 28 additions & 26 deletions desks/realm/app/bedrock.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@

%create-initial-spaces-paths
(create-initial-spaces-paths:db state bowl)
%toggle-hide-logs
(toggle-hide-logs:db +.act state bowl)
==
[cards this]
::
Expand Down Expand Up @@ -131,7 +133,7 @@
=/ thepathrow (~(got by paths.state) t.t.path)
:: if the @da they passed was behind, %give them the current version, and %kick them
?: (gth updated-at.thepathrow t)
~& >>> "{<src.bowl>} tried to sub on old @da {<t>}, %kicking them"
::~& >>> "{<src.bowl>} tried to sub on old @da {<t>}, %kicking them"
=/ thepeers (~(got by peers.state) t.t.path)
=/ tbls (tables-by-path:db tables.state t.t.path)
=/ dels=(list [@da db-del-change])
Expand All @@ -151,7 +153,7 @@
::=/ thepathrow (~(get by paths-table.state) t.t.path)
:::~ [%give %fact ~ chat-path-row+!>(thepathrow)]
::==
~& > "{(scow %p src.bowl)} subbed to {(spud path)}"
::~& > "{(scow %p src.bowl)} subbed to {(spud path)}"
~
:: /vent/~zod/~2000.1.1
[%vent @ @ ~] :: poke response comes on this path
Expand Down Expand Up @@ -209,32 +211,32 @@
^- (quip card _this)
?+ wire ~&(wire ~&(sign !!))
[%remote-scry %callback ~]
~& > "remote-scry/callback on-agent {<-.sign>}"
~& +.sign
::~& > "remote-scry/callback on-agent {<-.sign>}"
::~& +.sign
`this
[%dbpoke ~]
?+ -.sign `this
%poke-ack
?~ p.sign `this
~& >>> "%db: {<(spat wire)>} dbpoke failed"
~& >>> p.sign
::~& >>> "%db: {<(spat wire)>} dbpoke failed"
::~& >>> p.sign
`this
==
[%selfpoke ~]
?+ -.sign `this
%poke-ack
?~ p.sign `this
~& >>> "%db: {<(spat wire)>} selfpoke failed"
::~& >>> "%db: {<(spat wire)>} selfpoke failed"
`this
==
[%spaces ~]
?+ -.sign !!
%watch-ack
?~ p.sign %- (slog leaf+"{<dap.bowl>}: subscribed to spaces" ~) `this
~& >>> "{<dap.bowl>}: spaces subscription failed"
::~& >>> "{<dap.bowl>}: spaces subscription failed"
`this
%kick
~& > "{<dap.bowl>}: spaces kicked us, resubscribing..."
::~& > "{<dap.bowl>}: spaces kicked us, resubscribing..."
:_ this
:~ [%pass /spaces %agent [our.bowl %spaces] %watch /updates]
==
Expand All @@ -255,20 +257,20 @@
?- -.sign
%poke-ack
?~ p.sign `this
~& >>> "%db: {<(spat wire)>} /next/[path] failed"
~& >>> p.sign
::~& >>> "%db: {<(spat wire)>} /next/[path] failed"
::~& >>> p.sign
`this
%watch-ack
?~ p.sign `this
~& >>> "{<dap.bowl>}: /next/[path] subscription failed"
::~& >>> "{<dap.bowl>}: /next/[path] subscription failed"
`this
%kick
=/ pathrow (~(get by paths.state) +.wire)
?: =(~ pathrow)
~& >>> "got a %kick on {(spud +.wire)} that we are ignoring because that path is not in our state"
::~& >>> "got a %kick on {(spud +.wire)} that we are ignoring because that path is not in our state"
`this
=/ newpath (weld /next/(scot %da updated-at:(need pathrow)) path:(need pathrow))
~& > "{<dap.bowl>}: /next/[path] kicked us, resubbing {(spud newpath)}"
::~& > "{<dap.bowl>}: /next/[path] kicked us, resubbing {(spud newpath)}"
:_ this
:~
[%pass wire %agent [src.bowl dap.bowl] %watch newpath]
Expand All @@ -280,7 +282,7 @@
^- (quip card state-0)
=/ dbpath=path +.wire
=/ factmark -.+.sign
~& >> "%fact on {(spud wire)}: {<factmark>}"
::~& >> "%fact on {(spud wire)}: {<factmark>}"
?+ factmark
:: default case:
~& >>> "UNHANDLED FACT type"
Expand All @@ -307,7 +309,7 @@
?> ?=(%relay -.data.row.change)
=/ uobj=(unit row) (get-db:db type.data.row.change path.data.row.change id.data.row.change state)
?~ uobj :: if we DONT have the obj already, remote-scry it
~& >>> "asking for remote-scry"
::~& >>> "asking for remote-scry"
:~ [
%pass
/remote-scry/callback
Expand All @@ -323,7 +325,7 @@
?. ?=(%relay type.row.change) ~
?> ?=(%relay -.data.row.change)
?: deleted.data.row.change ~ :: if the root-obj is deleted, don't remote-scry it
~& >>> "asking for remote-scry"
::~& >>> "asking for remote-scry"
:~ [
%pass
/remote-scry/callback
Expand Down Expand Up @@ -392,7 +394,7 @@
?=(%relay -.data.row.change)
=(%.y deleted.data.row.change)
==
~& >>> "{<our.bowl>} is del-db ing {<type.data.row.change>} {<ship.id.data.row.change>} {<t.id.data.row.change>}"
::~& >>> "{<our.bowl>} is del-db ing {<type.data.row.change>} {<ship.id.data.row.change>} {<t.id.data.row.change>}"
(del-db:db type.data.row.change path.data.row.change id.data.row.change state (add now.bowl index))
state
$(index +(index), state (process-db-change:db dbpath change state bowl), result-cards (weld (weld result-cards new-scry) pokes))
Expand Down Expand Up @@ -436,15 +438,15 @@
?- -.sign
%poke-ack
?~ p.sign `this
~& >>> "%realm-chat: {<(spat wire)>} dbpoke failed"
~& >>> p.sign
::~& >>> "%realm-chat: {<(spat wire)>} dbpoke failed"
::~& >>> p.sign
`this
%watch-ack
?~ p.sign `this
~& >>> "{<dap.bowl>}: /db subscription failed"
::~& >>> "{<dap.bowl>}: /db subscription failed"
`this
%kick
~& > "{<dap.bowl>}: /db kicked us, resubscribing..."
::~& > "{<dap.bowl>}: /db kicked us, resubscribing..."
:_ this
:~
[%pass /db %agent [our.bowl %chat-db] %watch /db]
Expand All @@ -457,15 +459,15 @@
++ on-leave
|= =path
^- (quip card _this)
~& "Unsubscribe by: {<src.bowl>} on: {<path>}"
::~& "Unsubscribe by: {<src.bowl>} on: {<path>}"
`this
::
++ on-arvo
|= [=wire =sign-arvo]
^- (quip card _this)
?+ wire !!
[%remote-scry %callback ~]
~& > "remote-scry/callback on-arvo"
::~& > "remote-scry/callback on-arvo"
?+ -.sign-arvo `this
%ames
?+ -.+.sign-arvo `this
Expand All @@ -486,8 +488,8 @@
==
==
[%remote-scry %cullback ~]
~& > "remote-scry cullback we culled something"
~& > -.sign-arvo
::~& > "remote-scry cullback we culled something"
::~& > -.sign-arvo
`this
[%timer ~]
~& >>> "unhandled on-arvo %timer"
Expand Down
52 changes: 31 additions & 21 deletions desks/realm/lib/db.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
::
:: helpers
::
++ maybe-log
|= [hide-debug=? msg=*]
?: =(%.y hide-debug) ~
~& msg
~
++ got-db
|= [=type:common =path =id:common state=state-0]
^- row
Expand Down Expand Up @@ -602,7 +607,7 @@
:: %initiate, every ship in the members list, regardless of role or joined status
|= [[=path sp=[=ship space=cord] sr=role:mstore] state=state-0 =bowl:gall]
^- (quip card state-0)
~& %create-from-space
=/ log1 (maybe-log hide-logs.state %create-from-space)
=/ members .^(view:mstore %gx /(scot %p our.bowl)/spaces/(scot %da now.bowl)/(scot %p ship.sp)/(scot %tas space.sp)/members/noun)
?> ?=(%members -.members)
=/ filtered-members
Expand Down Expand Up @@ -745,7 +750,7 @@
:: kick subs to force them to re-sub for next update
[%give %kick [path-sub-wire ~] ~]
==
~& > "publishing to {(spud path-sub-wire)} (and also kicking)"
=/ log1 (maybe-log hide-logs.state "publishing to {(spud path-sub-wire)} (and also kicking)")

[cards state]
::
Expand All @@ -770,8 +775,8 @@
:: kick subs to force them to re-sub for next update
[%give %kick [path-sub-wire ~] ~]
==
~& > "poking %delete-path to {(scow %p ship)}"
~& > "publishing to {(spud path-sub-wire)} (and also kicking those subs)"
=/ log1 (maybe-log hide-logs.state "poking %delete-path to {(scow %p ship)}")
=/ log2 (maybe-log hide-logs.state "publishing to {(spud path-sub-wire)} (and also kicking those subs)")

:: local state updates
:: update paths table
Expand All @@ -787,7 +792,7 @@
++ get-path
|= [[=path-row peers=ship-roles] state=state-0 =bowl:gall]
^- (quip card state-0)
~& "%get-path {<path.path-row>}"
=/ log1 (maybe-log hide-logs.state "%get-path {<path.path-row>}")
:: ensure the path doesn't already exist
=/ pre-existing (~(get by paths.state) path.path-row)
?> =(~ pre-existing)
Expand Down Expand Up @@ -833,21 +838,21 @@
(weld /next/(scot %da updated-at.path-row) path.path-row)
]
==
~& > "subbing to"
~& > subs
=/ log1 (maybe-log hide-logs.state "subbing to")
=/ log2 (maybe-log hide-logs.state subs)
=/ cards=(list card) (weld subs sub-facts)
[cards state]
::
++ delete-path
|= [=path state=state-0 =bowl:gall]
^- (quip card state-0)
:: ensure the path actually exists
~& >>> "attempting to delete {<path>}"
=/ log1 (maybe-log hide-logs.state "attempting to delete {<path>}")
=/ path-row=path-row (~(got by paths.state) path)
:: ensure this came from host ship
?> =(host.path-row src.bowl)

~& > "we either got kicked or the host deleted the whole path: {(spud path)}"
=/ log2 (maybe-log hide-logs.state "we either got kicked or the host deleted the whole path: {(spud path)}")

:: remove from paths table, and peers table
=. paths.state (~(del by paths.state) path)
Expand Down Expand Up @@ -887,16 +892,16 @@
:: ensure the path actually exists
=/ path-row=path-row (~(got by paths.state) path.row)
?. (has-create-permissions path-row row state bowl)
~& >>> "{(scow %p src.bowl)} tried to create a %{(scow %tas type.row)} row where they didn't have permissions"
=/ log1 (maybe-log hide-logs.state "{(scow %p src.bowl)} tried to create a %{(scow %tas type.row)} row where they didn't have permissions")
[~[kickcard] state]
:: forward the request if we aren't the host
?. =(host.path-row our.bowl)
~& >> "{<src.bowl>} tried to have us ({<our.bowl>}) create a row in {<path.path-row>} where we are not the host. forwarding the poke to the host: {<host.path-row>}"
=/ log2 (maybe-log hide-logs.state "{<src.bowl>} tried to have us ({<our.bowl>}) create a row in {<path.path-row>} where we are not the host. forwarding the poke to the host: {<host.path-row>}")
:_ state
[%pass /dbpoke %agent [host.path-row dap.bowl] %poke %db-action !>([%create req-id input-row])]~
:: ensure that the row meets constraints
?. (meets-constraints path-row row state bowl)
~& >>> "{(scow %p src.bowl)} tried to create a %{(scow %tas type.row)} row where they violated constraints"
=/ log3 (maybe-log hide-logs.state "{(scow %p src.bowl)} tried to create a %{(scow %tas type.row)} row where they violated constraints")
[~[kickcard] state]

:: update path
Expand All @@ -917,25 +922,25 @@
[%give %fact ~[vent-path] db-vent+!>([%row row schema.input-row])]
kickcard
==
~& > "publishing new row to {(spud path-sub-wire)} (and also kicking)"
=/ log4 (maybe-log hide-logs.state "publishing new row to {(spud path-sub-wire)} (and also kicking)")

[cards state]
::
++ edit :: falls back to existing db schema if schema from poke input is null
:: generally, you'd only bother passing the schema if you are changing the version of the row
::db &db-action [%edit [our ~2023.5.22..17.21.47..9d73] /example %foo 0 [%general ~[2 'b']] ~]
|= [[=id:common =input-row] state=state-0 =bowl:gall]
~& "%bedrock agent - %edit poke"
=/ log1 (maybe-log hide-logs.state "%bedrock agent - %edit poke")
^- (quip card state-0)
:: permissions
=/ old-row (~(got by (~(got by (~(got by tables.state) type.input-row)) path.input-row)) id) :: old row must first exist
=/ path-row=path-row (~(got by paths.state) path.input-row)
?. (has-edit-permissions path-row old-row state bowl)
~& >>> "{(scow %p src.bowl)} tried to edit a %{(scow %tas type.input-row)} row where they didn't have permissions"
=/ log2 (maybe-log hide-logs.state "{(scow %p src.bowl)} tried to edit a %{(scow %tas type.input-row)} row where they didn't have permissions")
`state
:: forward the request if we aren't the host
?. =(host.path-row our.bowl)
~& >> "{<src.bowl>} tried to have us ({<our.bowl>}) edit a row in {<path.path-row>} where we are not the host. forwarding the poke to the host: {<host.path-row>}"
=/ log3 (maybe-log hide-logs.state "{<src.bowl>} tried to have us ({<our.bowl>}) edit a row in {<path.path-row>} where we are not the host. forwarding the poke to the host: {<host.path-row>}")
:_ state
[%pass /dbpoke %agent [host.path-row dap.bowl] %poke %db-action !>([%edit id input-row])]~

Expand Down Expand Up @@ -973,7 +978,7 @@
:: kick subs to force them to re-sub for next update
[%give %kick [path-sub-wire ~] ~]
==
~& > "publishing edited row to {(spud path-sub-wire)} and kicking everyone there"
=/ log4 (maybe-log hide-logs.state "publishing edited row to {(spud path-sub-wire)} and kicking everyone there")

[cards state]
::
Expand All @@ -987,11 +992,11 @@
=/ old-row (~(got by tbl) id) :: old row must first exist
=/ path-row=path-row (~(got by paths.state) path)
?. (has-delete-permissions path-row old-row state bowl)
~& >>> "{(scow %p src.bowl)} tried to delete a %{(scow %tas type)} row where they didn't have permissions"
=/ log1 (maybe-log hide-logs.state "{(scow %p src.bowl)} tried to delete a %{(scow %tas type)} row where they didn't have permissions")
`state
:: forward the request if we aren't the host
?. =(host.path-row our.bowl)
~& >> "{<src.bowl>} tried to have us ({<our.bowl>}) remove a row in {<path.path-row>} where we are not the host. forwarding the poke to the host: {<host.path-row>}"
=/ log2 (maybe-log hide-logs.state "{<src.bowl>} tried to have us ({<our.bowl>}) remove a row in {<path.path-row>} where we are not the host. forwarding the poke to the host: {<host.path-row>}")
:_ state
[%pass /dbpoke %agent [host.path-row dap.bowl] %poke %db-action !>([%remove type path id])]~

Expand All @@ -1016,7 +1021,7 @@
:: kick foreign ship subs to force them to re-sub for next update
[%give %kick [foreign-ship-sub-wire ~] ~]
==
~& > "publishing %del-row type: {<type>} id: {<id>} to {(spud foreign-ship-sub-wire)} + kicking those subs"
=/ log3 (maybe-log hide-logs.state "publishing %del-row type: {<type>} id: {<id>} to {(spud foreign-ship-sub-wire)} + kicking those subs")

[cards state]
::
Expand All @@ -1026,7 +1031,7 @@
::bedrock &db-action [%relay [~bus now] /target %relay 0 [%relay [~zod ~2023.6.13..15.57.34..aa97] %foo /example 0 %all %.n] ~]
|= [[=req-id =input-row] state=state-0 =bowl:gall]
^- (quip card state-0)
~& %relay
=/ log1 (maybe-log hide-logs.state %relay)
:: first check that the input is actually a %relay
?+ -.data.input-row !!
%relay
Expand Down Expand Up @@ -1055,6 +1060,11 @@
==
==
::
++ toggle-hide-logs
|= [toggle=? state=state-0 =bowl:gall]
^- (quip card state-0)
=. hide-logs.state toggle
`state
:: on-init selfpoke
++ create-initial-spaces-paths
|= [state=state-0 =bowl:gall]
Expand Down
3 changes: 3 additions & 0 deletions desks/realm/sur/db.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
=paths
=peers
=del-log
hide-logs=? :: default hidden %.y
==

+$ schemas (map [=type:common v=@ud] schema)
Expand Down Expand Up @@ -155,6 +156,8 @@
[%remove =type:common =path =id:common] :: %host deleting the row, sends %delete to all peers
[%relay =req-id =input-row] :: like %create, but for creating a %relay (relay:common)
[%create-initial-spaces-paths ~]

[%toggle-hide-logs toggle=?]
==
::
+$ ship-roles (list [s=@p =role])
Expand Down