Skip to content

Commit

Permalink
vitals: support /app/ping state %3
Browse files Browse the repository at this point in the history
  • Loading branch information
pkova committed Mar 20, 2024
1 parent ca63cf3 commit b0db467
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 18 deletions.
44 changes: 35 additions & 9 deletions desk/sur/vitals.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,42 @@
=result
==
::
+$ ship-state
$% [%idle ~]
[%poking ~]
[%http until=@da]
[%waiting until=@da]
==
::
+$ ping
$: version=@
ships=(set ship)
nonce=@ud
$= plan
$~ [%nat ~]
$% [%nat ~]
[%pub ip=(unit @t)]
[%off ~]
[%one ~]
$% [%0 ships=(map ship [=rift =ship-state])]
$: %1
ships=(set ship)
nonce=@ud
$= plan
$~ [%nat ~]
$% [%nat ~]
[%pub ip=(unit @t)]
==
==
::
$: %2
ships=(set ship)
nonce=@ud
$= plan
$~ [%nat ~]
$% [%nat ~]
[%pub ip=(unit @t)]
[%off ~]
[%one ~]
==
==
::
$: %3
mode=?(%formal %informal)
pokes=@ud
timer=(unit [=wire date=@da])
galaxy=@p
==
==
--
49 changes: 40 additions & 9 deletions desk/ted/vitals/connection-check.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
:: check if we can contact our own galaxy
;< =ping:vitals bind:m (scry:io ping:vitals ~[%gx %ping %noun])
;< gqos=qos:ames bind:m (scry:io qos:ames ~[%gx %vitals %galaxy %vitals-qos])
?: &(!=(%live -.gqos) !=(%off -.plan.ping))
?: !(galaxy-reachable ping gqos)
(post-result [%no-our-galaxy last-contact.gqos])
:: set pending to %trying-target
;< ~ bind:m (update-status [%trying-target ~])
Expand All @@ -46,23 +46,30 @@
:: if we're a moon, check if we can contact our planet
::
:: NN: failing to contact our sponsor is only a failure condition for moons,
:: since currently only moons receive additional routing help from their
:: sponsors
:: since currently only moons require the direct sponsor to be online for
:: peers to grab the moon keys
:: NN: we do this after the initial target check because if we're a moon and
:: our planet is down, it's useful to talk to ships that still have live
:: wires (e.g. for troubleshooting); thus, by waiting to perform this
:: check, we don't report %no-our-planet for every connectivity check
:: when attempting to track down a live peer from whom to seek help
::
;< sqos=qos:ames
;< moon-sponsor-reachable=?
bind:m
=/ mm (strand ,qos:ames)
=/ mm (strand ,?)
^- form:mm
?. ?=(%earl (clan:title our))
(pure:mm [%live *@da])
(scry:io qos:ames ~[%gx %vitals %sponsor %vitals-qos])
?. ?=(%live -.sqos)
(post-result [%no-our-planet last-contact.sqos])
(pure:mm %.y)
=/ sponsor=@p (end 5 our)
;< ~ bind:mm (update-status [%trying-sponsor sponsor])
;< pchek=(unit) bind:mm (check-online sponsor target-timeout:vitals)
?: ?=([%$ %$] pchek)
(pure:mm %.y)
(pure:mm %.n)
::
?: !moon-sponsor-reachable
;< pqos=qos:ames bind:m (scry:io qos:ames ~[%gx %vitals %sponsor %vitals-qos])
(post-result [%no-our-planet last-contact.pqos])
:: early exit; if target is a galaxy, there's nothing more we can check
?: ?=(%czar (clan:title target))
(galaxy-down target)
Expand Down Expand Up @@ -93,6 +100,30 @@
?: u.live
[%no-sponsor-hit i.sponsors]
[%no-sponsor-miss i.sponsors]
::
++ galaxy-reachable
|= [=ping:vitals =qos:ames]
^- ?
?- -.ping
%0
?=(%live -.qos)
::
%1
?: ?=(%pub -.plan.ping)
%.y
?=(%live -.qos)
::
%2
?. ?=(%nat -.plan.ping)
%.y
?=(%live -.qos)
::
%3
?: ?=(%informal mode.ping)
%.y
?=(%live -.qos)
==
::
++ update-status
|= =pending:vitals
=/ m (strand ,~)
Expand Down

0 comments on commit b0db467

Please sign in to comment.