on master help sign in
Got liveness check working
983ad42iko
frontend/src/Main.elm+1−1
@@ -79,7 +79,7 @@ main =
79 { init =
79 { init =
80 ( { ship = Nothing
80 ( { ship = Nothing
81 , search = ""
81 , search = ""
82− , initiatedSearch = Just "urbit"
82+ , initiatedSearch = Nothing
83 , searchResults = []
83 , searchResults = []
84 , resultTimelines = Dict.empty
84 , resultTimelines = Dict.empty
85 , engines = []
85 , engines = []
zod/seax/app/seax.hoon+57−7
@@ -11,10 +11,16 @@ $:
11+$ state-0
11+$ state-0
12$:
12$:
13 search-subscriptions=(map query search-state)
13 search-subscriptions=(map query search-state)
14+ peers=(set @p)
15+ alive-peers=(set @p)
14==
16==
15+$ poke
17+$ poke
16 $%
18 $%
17− [%search query=tape]
19+ :: [%search query=tape]
20+ [%liveness-check ~]
21+ [%add-peers (set @p)]
22+ :: [%ping ~]
23+ :: [%pong ~]
18 ==
24 ==
19++ rank-results
25++ rank-results
20 |= search-results=(map term (unit (list search-result)))
26 |= search-results=(map term (unit (list search-result)))
@@ -39,6 +45,7 @@ $:
39 ^- task:iris
45 ^- task:iris
40 [%request [%'GET' (crip (url.engine (trip query))) ~ ~] *outbound-config:iris]
46 [%request [%'GET' (crip (url.engine (trip query))) ~ ~] *outbound-config:iris]
41 [%pass ~[%search-result query engine-name] %arvo %i req]
47 [%pass ~[%search-result query engine-name] %arvo %i req]
48+ ++ liveness-interval ~s30
42--
49--
43
50
44=/ state *state-0
51=/ state *state-0
@@ -62,7 +69,6 @@ $:
62 search-results.search-state
69 search-results.search-state
63=* sink-for-query
70=* sink-for-query
64 |= =query
71 |= =query
65− ~& (~(get by search-subscriptions.state) query)
66 [(current-engines query) (search-results query)]
72 [(current-engines query) (search-results query)]
67=* sink
73=* sink
68 |= =query
74 |= =query
@@ -72,7 +78,9 @@ $:
72%- agent:dbug
78%- agent:dbug
73|_ =bowl:gall
79|_ =bowl:gall
74+* this .
80+* this .
81+ liveness-behn-card [%pass /check-liveness %arvo %b %wait (add now.bowl liveness-interval)]
75−++ on-init `..on-init
82+++ on-init
83+ [~[liveness-behn-card] this]
76++ on-save !>(state)
84++ on-save !>(state)
77++ on-load
85++ on-load
78 |= =vase
86 |= =vase
@@ -84,7 +92,18 @@ $:
84++ on-poke
92++ on-poke
85 |= =cage
93 |= =cage
86 ^- (quip card:agent:gall _this)
94 ^- (quip card:agent:gall _this)
87− `this
95+ ?> ?=(%noun -.cage)
96+ =/ poke !<(poke +.cage)
97+ ?- -.poke
98+ %liveness-check
99+ [~[liveness-behn-card] this]
100+ %add-peers
101+ `this(peers.state (~(uni in peers.state) +.poke))
102+ ==
103+
104+ :: %ping
105+
106+
88
107
89++ on-watch
108++ on-watch
90 |= =path
109 |= =path
@@ -104,13 +123,22 @@ $:
104 =. search-subscriptions.state
123 =. search-subscriptions.state
105 (~(put by search-subscriptions.state) query subscription)
124 (~(put by search-subscriptions.state) query subscription)
106 [~[flush:(sink query)] this]
125 [~[flush:(sink query)] this]
126+ [%ping ~]
127+ ~& path
128+ :-
129+ :~
130+ [%give %fact ~ %noun !>(%pong)]
131+ [%give %kick ~ ~]
132+ ==
133+ this
134+
107 ==
135 ==
108
136
109:: This was not tested because it requires waiting 12 hours.
137:: This was not tested because it requires waiting 12 hours.
110++ on-leave
138++ on-leave
111 |= =path
139 |= =path
112− ?+ path !!
140+ ?+ path `this
113− [%search query ~]
141+ [%search query ~]
114 =/ query +<.path
142 =/ query +<.path
115 ~& path
143 ~& path
116 =/ search-state (~(got by search-subscriptions.state) query)
144 =/ search-state (~(got by search-subscriptions.state) query)
@@ -125,7 +153,17 @@ $:
125++ on-peek
153++ on-peek
126 |= path
154 |= path
127 ~
155 ~
156+++ on-agent
128−++ on-agent |=([wire sign:agent:gall] !!)
157+ |= [=wire =sign:agent:gall]
158+ ?+ wire `this
159+ [%alive ~]
160+ ?+ -.sign `this
161+ %fact
162+ ~& "{<src.bowl>} is alive"
163+ =. alive-peers.state (~(put in alive-peers.state) src.bowl)
164+ `this
165+ ==
166+ ==
129++ on-arvo
167++ on-arvo
130 |= [=wire =sign-arvo]
168 |= [=wire =sign-arvo]
131 ^- (quip card:agent:gall _this)
169 ^- (quip card:agent:gall _this)
@@ -149,6 +187,18 @@ $:
149 =^ card sink (sync:sink (sink-for-query query))
187 =^ card sink (sync:sink (sink-for-query query))
150 ~& (current-engines query)
188 ~& (current-engines query)
151 [~[card] this]
189 [~[card] this]
190+ [%check-liveness ~]
191+ =/ checks
192+ %+ turn ~(tap in peers.state)
193+ |= peer=@p
194+ [%pass /alive %agent [peer %seax] %watch /ping]
195+ =. peers.state alive-peers.state
196+ =. alive-peers.state *(set @p)
197+ =/ timer
198+ liveness-behn-card
199+ :-
200+ [timer checks]
201+ this
152 ==
202 ==
153++ on-fail
203++ on-fail
154 |= [term =tang]
204 |= [term =tang]