2019-09-26 22:00:11 +03:00
|
|
|
/- spider
|
2021-09-26 02:45:05 +03:00
|
|
|
/+ libstrand=strand, default-agent, verb, server, dbug
|
2019-11-16 14:25:30 +03:00
|
|
|
=, strand=strand:libstrand
|
2021-06-14 22:28:23 +03:00
|
|
|
~% %spider-top ..part ~
|
2019-09-26 07:12:58 +03:00
|
|
|
|%
|
2019-11-19 07:36:21 +03:00
|
|
|
+$ card card:agent:gall
|
2019-11-16 14:25:30 +03:00
|
|
|
+$ thread thread:spider
|
|
|
|
+$ tid tid:spider
|
|
|
|
+$ input input:spider
|
|
|
|
+$ yarn (list tid)
|
|
|
|
+$ thread-form _*eval-form:eval:(strand ,vase)
|
2022-04-06 10:19:38 +03:00
|
|
|
+$ trying ?(%build %none)
|
2019-11-10 06:09:02 +03:00
|
|
|
+$ state
|
2019-11-16 14:25:30 +03:00
|
|
|
$: starting=(map yarn [=trying =vase])
|
2022-04-06 10:19:38 +03:00
|
|
|
running=(axal thread-form)
|
2019-11-16 14:25:30 +03:00
|
|
|
tid=(map tid yarn)
|
2021-09-25 09:50:21 +03:00
|
|
|
serving=(map tid [(unit @ta) =mark =desk])
|
2023-04-27 14:55:06 +03:00
|
|
|
scrying=(jug tid [=wire =ship =path])
|
2019-11-10 10:27:07 +03:00
|
|
|
==
|
|
|
|
::
|
2020-06-18 06:31:37 +03:00
|
|
|
+$ clean-slate-any
|
|
|
|
$^ clean-slate-ket
|
|
|
|
$% clean-slate-sig
|
2020-09-03 08:04:11 +03:00
|
|
|
clean-slate-1
|
2021-09-13 14:01:42 +03:00
|
|
|
clean-slate-2
|
2021-09-26 02:45:05 +03:00
|
|
|
clean-slate-3
|
2023-04-03 10:18:51 +03:00
|
|
|
clean-slate-4
|
2023-04-27 14:55:06 +03:00
|
|
|
clean-slate-5
|
2020-06-18 06:31:37 +03:00
|
|
|
clean-slate
|
|
|
|
==
|
|
|
|
::
|
2019-11-10 10:27:07 +03:00
|
|
|
+$ clean-slate
|
2023-04-27 14:55:06 +03:00
|
|
|
$: %6
|
|
|
|
starting=(map yarn [=trying =vase])
|
|
|
|
running=(list yarn)
|
|
|
|
tid=(map tid yarn)
|
|
|
|
serving=(map tid [(unit @ta) =mark =desk])
|
|
|
|
scrying=(jug tid [wire ship path])
|
|
|
|
==
|
|
|
|
::
|
|
|
|
+$ clean-slate-5
|
2023-04-03 10:18:51 +03:00
|
|
|
$: %5
|
|
|
|
starting=(map yarn [=trying =vase])
|
|
|
|
running=(list yarn)
|
|
|
|
tid=(map tid yarn)
|
|
|
|
serving=(map tid [(unit @ta) =mark =desk])
|
2023-04-27 14:55:06 +03:00
|
|
|
scrying=(map tid [ship path])
|
2023-04-03 10:18:51 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
+$ clean-slate-4
|
2021-09-26 02:45:05 +03:00
|
|
|
$: %4
|
|
|
|
starting=(map yarn [=trying =vase])
|
|
|
|
running=(list yarn)
|
|
|
|
tid=(map tid yarn)
|
|
|
|
serving=(map tid [(unit @ta) =mark =desk])
|
|
|
|
==
|
|
|
|
::
|
|
|
|
+$ clean-slate-3
|
2021-09-13 14:01:42 +03:00
|
|
|
$: %3
|
|
|
|
starting=(map yarn [=trying =vase])
|
|
|
|
running=(list yarn)
|
|
|
|
tid=(map tid yarn)
|
|
|
|
serving=(map tid [@ta =mark =desk])
|
|
|
|
==
|
|
|
|
::
|
|
|
|
+$ clean-slate-2
|
2020-09-03 08:04:11 +03:00
|
|
|
$: %2
|
2020-06-18 06:31:37 +03:00
|
|
|
starting=(map yarn [=trying =vase])
|
|
|
|
running=(list yarn)
|
|
|
|
tid=(map tid yarn)
|
2020-09-03 07:47:34 +03:00
|
|
|
serving=(map tid [@ta =mark])
|
2020-06-18 06:31:37 +03:00
|
|
|
==
|
|
|
|
::
|
2020-09-03 08:04:11 +03:00
|
|
|
+$ clean-slate-1
|
|
|
|
$: %1
|
|
|
|
starting=(map yarn [=trying =vase])
|
|
|
|
running=(list yarn)
|
|
|
|
tid=(map tid yarn)
|
|
|
|
==
|
|
|
|
::
|
2020-06-18 06:31:37 +03:00
|
|
|
+$ clean-slate-ket
|
|
|
|
$: starting=(map yarn [trying=?(%build %find %none) =vase])
|
|
|
|
running=(list yarn)
|
|
|
|
tid=(map tid yarn)
|
|
|
|
==
|
|
|
|
::
|
|
|
|
+$ clean-slate-sig
|
|
|
|
$: starting=~
|
2019-11-16 14:25:30 +03:00
|
|
|
running=(list yarn)
|
|
|
|
tid=(map tid yarn)
|
2019-11-10 10:27:07 +03:00
|
|
|
==
|
|
|
|
--
|
|
|
|
::
|
2021-09-26 02:45:05 +03:00
|
|
|
%- agent:dbug
|
2019-11-19 07:36:21 +03:00
|
|
|
^- agent:gall
|
2019-11-07 09:19:32 +03:00
|
|
|
=| =state
|
|
|
|
=<
|
2019-11-15 23:46:11 +03:00
|
|
|
%+ verb |
|
2021-06-14 22:28:23 +03:00
|
|
|
~% %spider-agent ..bind-eyre ~
|
2019-11-19 07:36:21 +03:00
|
|
|
|_ =bowl:gall
|
2019-11-10 10:27:07 +03:00
|
|
|
+* this .
|
2019-11-07 09:19:32 +03:00
|
|
|
spider-core +>
|
2019-11-10 10:27:07 +03:00
|
|
|
sc ~(. spider-core bowl)
|
|
|
|
def ~(. (default-agent this %|) bowl)
|
2021-07-19 15:17:55 +03:00
|
|
|
bec byk.bowl(r da+now.bowl)
|
2019-09-26 07:12:58 +03:00
|
|
|
::
|
2021-09-26 02:45:05 +03:00
|
|
|
++ on-init
|
2020-09-03 07:47:34 +03:00
|
|
|
^- (quip card _this)
|
|
|
|
:_ this
|
2020-09-03 08:04:11 +03:00
|
|
|
~[bind-eyre:sc]
|
2019-11-10 10:27:07 +03:00
|
|
|
++ on-save clean-state:sc
|
2019-11-10 06:09:02 +03:00
|
|
|
++ on-load
|
2020-06-18 06:31:37 +03:00
|
|
|
|^
|
2019-11-10 06:09:02 +03:00
|
|
|
|= old-state=vase
|
2020-06-18 06:31:37 +03:00
|
|
|
=+ !<(any=clean-slate-any old-state)
|
|
|
|
=? any ?=(^ -.any) (old-to-1 any)
|
|
|
|
=? any ?=(~ -.any) (old-to-1 any)
|
2021-09-26 02:45:05 +03:00
|
|
|
=^ upgrade-cards any
|
2020-09-03 08:04:11 +03:00
|
|
|
(old-to-2 any)
|
2021-09-13 14:01:42 +03:00
|
|
|
=. any (old-to-3 any)
|
2021-09-26 02:45:05 +03:00
|
|
|
=. any (old-to-4 any)
|
2023-04-03 10:18:51 +03:00
|
|
|
=. any (old-to-5 any)
|
2023-04-27 14:55:06 +03:00
|
|
|
=. any (old-to-6 any)
|
|
|
|
?> ?=(%6 -.any)
|
2020-06-18 06:31:37 +03:00
|
|
|
::
|
|
|
|
=. tid.state tid.any
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ yarns=(list yarn)
|
2020-06-18 06:31:37 +03:00
|
|
|
%+ welp running.any
|
|
|
|
~(tap in ~(key by starting.any))
|
2019-11-10 06:09:02 +03:00
|
|
|
|- ^- (quip card _this)
|
2023-04-27 14:59:35 +03:00
|
|
|
?~ yarns
|
2020-09-25 22:36:55 +03:00
|
|
|
[~[bind-eyre:sc] this]
|
2019-11-10 10:27:07 +03:00
|
|
|
=^ cards-1 state
|
2023-04-27 14:55:06 +03:00
|
|
|
%. [(yarn-to-tid i.yarns) nice=%.n]
|
|
|
|
:: the |sc core needs to now about the previous
|
|
|
|
:: scrying state in order to send $yawns to %ames
|
|
|
|
::
|
|
|
|
%*(handle-stop-thread sc scrying.state scrying.any)
|
2019-11-10 10:27:07 +03:00
|
|
|
=^ cards-2 this
|
2019-11-16 14:25:30 +03:00
|
|
|
$(yarns t.yarns)
|
2021-09-06 21:13:07 +03:00
|
|
|
[:(weld upgrade-cards cards-1 cards-2) this]
|
2020-06-18 06:31:37 +03:00
|
|
|
::
|
|
|
|
++ old-to-1
|
|
|
|
|= old=clean-slate-ket
|
2020-09-03 08:04:11 +03:00
|
|
|
^- clean-slate-1
|
2020-06-18 06:31:37 +03:00
|
|
|
1+old(starting (~(run by starting.old) |=([* v=vase] none+v)))
|
2020-09-03 08:04:11 +03:00
|
|
|
::
|
|
|
|
++ old-to-2
|
|
|
|
|= old=clean-slate-any
|
2021-09-13 14:01:42 +03:00
|
|
|
^- (quip card clean-slate-any)
|
2023-04-27 14:55:06 +03:00
|
|
|
?> ?=(?(%1 %2 %3 %4 %5 %6) -.old)
|
|
|
|
?: ?=(?(%2 %3 %4 %5 %6) -.old)
|
2020-09-03 08:04:11 +03:00
|
|
|
`old
|
|
|
|
:- ~[bind-eyre:sc]
|
|
|
|
:* %2
|
|
|
|
starting.old
|
|
|
|
running.old
|
|
|
|
tid.old
|
|
|
|
~
|
|
|
|
==
|
2021-09-13 14:01:42 +03:00
|
|
|
::
|
|
|
|
++ old-to-3
|
|
|
|
|= old=clean-slate-any
|
2021-09-26 02:45:05 +03:00
|
|
|
^- clean-slate-any
|
2023-04-27 14:55:06 +03:00
|
|
|
?> ?=(?(%2 %3 %4 %5 %6) -.old)
|
|
|
|
?: ?=(?(%3 %4 %5 %6) -.old)
|
2021-09-13 14:01:42 +03:00
|
|
|
old
|
|
|
|
:* %3
|
|
|
|
starting.old
|
|
|
|
running.old
|
|
|
|
tid.old
|
|
|
|
(~(run by serving.old) |=([id=@ta =mark] [id mark q.byk.bowl]))
|
|
|
|
==
|
2023-04-27 14:55:06 +03:00
|
|
|
::
|
2021-09-26 02:45:05 +03:00
|
|
|
++ old-to-4
|
|
|
|
|= old=clean-slate-any
|
2023-04-03 10:18:51 +03:00
|
|
|
^- clean-slate-any
|
2023-04-27 14:55:06 +03:00
|
|
|
?> ?=(?(%3 %4 %5 %6) -.old)
|
|
|
|
?: ?=(?(%4 %5 %6) -.old)
|
2021-09-26 02:45:05 +03:00
|
|
|
old
|
|
|
|
:* %4
|
|
|
|
starting.old
|
|
|
|
running.old
|
|
|
|
tid.old
|
|
|
|
(~(run by serving.old) |=([id=@ta =mark =desk] [`id mark q.byk.bowl]))
|
|
|
|
==
|
2023-04-03 10:18:51 +03:00
|
|
|
::
|
|
|
|
++ old-to-5
|
|
|
|
|= old=clean-slate-any
|
2023-04-27 14:55:06 +03:00
|
|
|
^- clean-slate-any
|
|
|
|
?> ?=(?(%4 %5 %6) -.old)
|
|
|
|
?: ?=(?(%5 %6) -.old) old
|
2023-04-03 10:18:51 +03:00
|
|
|
[%5 +.old(serving [serving.old ~])]
|
2023-04-27 14:55:06 +03:00
|
|
|
::
|
|
|
|
++ old-to-6
|
|
|
|
|= old=clean-slate-any
|
|
|
|
^- clean-slate
|
|
|
|
?> ?=(?(%5 %6) -.old)
|
|
|
|
?: ?=(%6 -.old) old
|
|
|
|
:- %6
|
|
|
|
%= +.old
|
|
|
|
scrying
|
|
|
|
%- ~(run by scrying.old)
|
|
|
|
|= [=ship =path]
|
|
|
|
%- ~(gas in *(set [wire ^ship ^path]))
|
|
|
|
:: XX +keen:strandio used /keen as the default wire
|
|
|
|
:: this assumes that any old thread used that as well
|
|
|
|
::
|
|
|
|
[/keen ship path]~
|
|
|
|
==
|
2020-06-18 06:31:37 +03:00
|
|
|
--
|
2019-11-10 06:09:02 +03:00
|
|
|
::
|
2019-11-07 09:19:32 +03:00
|
|
|
++ on-poke
|
2021-06-14 22:28:23 +03:00
|
|
|
~/ %on-poke
|
2019-09-26 07:12:58 +03:00
|
|
|
|= [=mark =vase]
|
|
|
|
^- (quip card _this)
|
2020-04-24 05:07:33 +03:00
|
|
|
?: ?=(%spider-kill mark)
|
|
|
|
(on-load on-save)
|
2019-09-26 07:12:58 +03:00
|
|
|
=^ cards state
|
2019-11-07 09:19:32 +03:00
|
|
|
?+ mark (on-poke:def mark vase)
|
2022-08-30 07:09:08 +03:00
|
|
|
%spider-input (on-poke-input:sc !<(input vase))
|
|
|
|
%spider-start (handle-start-thread:sc !<(start-args:spider vase))
|
|
|
|
%spider-inline (handle-inline-thread:sc !<(inline-args:spider vase))
|
|
|
|
%spider-stop (handle-stop-thread:sc !<([tid ?] vase))
|
2021-09-26 02:45:05 +03:00
|
|
|
%handle-http-request
|
2020-09-03 07:47:34 +03:00
|
|
|
(handle-http-request:sc !<([@ta =inbound-request:eyre] vase))
|
2019-09-26 07:12:58 +03:00
|
|
|
==
|
|
|
|
[cards this]
|
|
|
|
::
|
2019-11-07 09:19:32 +03:00
|
|
|
++ on-watch
|
2021-06-14 22:28:23 +03:00
|
|
|
~/ %on-watch
|
2019-10-11 01:30:24 +03:00
|
|
|
|= =path
|
|
|
|
^- (quip card _this)
|
|
|
|
=^ cards state
|
2019-11-07 09:19:32 +03:00
|
|
|
?+ path (on-watch:def path)
|
2019-11-16 14:25:30 +03:00
|
|
|
[%thread @ *] (on-watch:sc t.path)
|
|
|
|
[%thread-result @ ~] (on-watch-result:sc i.t.path)
|
2020-09-03 07:47:34 +03:00
|
|
|
[%http-response *] `state
|
2019-10-11 01:30:24 +03:00
|
|
|
==
|
|
|
|
[cards this]
|
|
|
|
::
|
2019-11-07 09:19:32 +03:00
|
|
|
++ on-leave on-leave:def
|
|
|
|
++ on-peek
|
2021-06-14 22:28:23 +03:00
|
|
|
~/ %on-peek
|
2019-09-29 07:44:31 +03:00
|
|
|
|= =path
|
|
|
|
^- (unit (unit cage))
|
2019-11-10 10:27:07 +03:00
|
|
|
?+ path (on-peek:def path)
|
|
|
|
[%x %tree ~]
|
2022-04-23 03:55:42 +03:00
|
|
|
``noun+!>((turn ~(tap of running.state) head))
|
2019-11-10 10:27:07 +03:00
|
|
|
::
|
2019-11-16 04:20:56 +03:00
|
|
|
[%x %starting @ ~]
|
2022-04-23 03:55:42 +03:00
|
|
|
``noun+!>((~(has of running.state) (~(got by tid.state) i.t.t.path)))
|
2019-11-10 10:27:07 +03:00
|
|
|
::
|
|
|
|
[%x %saxo @ ~]
|
2019-11-16 14:25:30 +03:00
|
|
|
``noun+!>((~(got by tid.state) i.t.t.path))
|
2019-09-29 07:44:31 +03:00
|
|
|
==
|
|
|
|
::
|
2019-11-07 09:19:32 +03:00
|
|
|
++ on-agent
|
2021-06-14 22:28:23 +03:00
|
|
|
~/ %on-agent
|
2019-11-19 07:36:21 +03:00
|
|
|
|= [=wire =sign:agent:gall]
|
2019-09-29 07:44:31 +03:00
|
|
|
^- (quip card _this)
|
|
|
|
=^ cards state
|
|
|
|
?+ wire !!
|
2019-11-16 14:25:30 +03:00
|
|
|
[%thread @ *] (on-agent:sc i.t.wire t.t.wire sign)
|
2019-09-29 07:44:31 +03:00
|
|
|
==
|
|
|
|
[cards this]
|
|
|
|
::
|
2019-11-07 09:19:32 +03:00
|
|
|
++ on-arvo
|
2021-06-14 22:28:23 +03:00
|
|
|
~/ %on-arvo
|
2019-09-26 07:12:58 +03:00
|
|
|
|= [=wire =sign-arvo]
|
|
|
|
^- (quip card _this)
|
|
|
|
=^ cards state
|
2019-11-07 09:19:32 +03:00
|
|
|
?+ wire (on-arvo:def wire sign-arvo)
|
2019-11-16 14:25:30 +03:00
|
|
|
[%thread @ *] (handle-sign:sc i.t.wire t.t.wire sign-arvo)
|
|
|
|
[%build @ ~] (handle-build:sc i.t.wire sign-arvo)
|
2020-09-03 08:04:11 +03:00
|
|
|
[%bind ~] `state
|
2019-09-26 07:12:58 +03:00
|
|
|
==
|
|
|
|
[cards this]
|
2019-11-16 14:25:30 +03:00
|
|
|
:: On unexpected failure, kill all outstanding strands
|
2019-09-29 07:44:31 +03:00
|
|
|
::
|
2019-11-16 04:20:56 +03:00
|
|
|
++ on-fail
|
|
|
|
|= [=term =tang]
|
|
|
|
^- (quip card _this)
|
2019-11-16 14:25:30 +03:00
|
|
|
%- (slog leaf+"spider crashed, killing all strands: {<term>}" tang)
|
2019-11-16 04:20:56 +03:00
|
|
|
(on-load on-save)
|
2019-09-26 07:12:58 +03:00
|
|
|
--
|
|
|
|
::
|
2022-04-06 10:19:38 +03:00
|
|
|
~% %spider-helper ..card ~
|
2019-11-19 07:36:21 +03:00
|
|
|
|_ =bowl:gall
|
2021-07-21 11:56:03 +03:00
|
|
|
++ bec `beak`byk.bowl(r da+now.bowl)
|
2020-09-03 08:04:11 +03:00
|
|
|
++ bind-eyre
|
|
|
|
^- card
|
|
|
|
[%pass /bind %arvo %e %connect [~ /spider] %spider]
|
|
|
|
::
|
2021-01-07 00:20:51 +03:00
|
|
|
++ new-thread-id
|
|
|
|
|= file=term
|
|
|
|
:((cury cat 3) file '--' (scot %uv (sham eny.bowl)))
|
|
|
|
::
|
2020-09-03 07:47:34 +03:00
|
|
|
++ handle-http-request
|
2021-06-14 22:28:23 +03:00
|
|
|
~/ %handle-http-request
|
2020-09-03 07:47:34 +03:00
|
|
|
|= [eyre-id=@ta =inbound-request:eyre]
|
|
|
|
^- (quip card _state)
|
2023-05-08 19:08:12 +03:00
|
|
|
?> authenticated.inbound-request
|
2021-09-26 02:45:05 +03:00
|
|
|
=/ url
|
2020-09-03 07:47:34 +03:00
|
|
|
(parse-request-line:server url.request.inbound-request)
|
2021-08-26 05:12:54 +03:00
|
|
|
?> ?=([%spider @t @t @t @t ~] site.url)
|
|
|
|
=* desk i.t.site.url
|
|
|
|
=* input-mark i.t.t.site.url
|
|
|
|
=* thread i.t.t.t.site.url
|
|
|
|
=* output-mark i.t.t.t.t.site.url
|
2021-01-07 00:20:51 +03:00
|
|
|
=/ =tid (new-thread-id thread)
|
2020-09-03 07:47:34 +03:00
|
|
|
=. serving.state
|
2021-09-25 09:50:21 +03:00
|
|
|
(~(put by serving.state) tid [`eyre-id output-mark desk])
|
2021-06-14 22:28:23 +03:00
|
|
|
:: TODO: speed this up somehow. we spend about 15ms in this arm alone
|
|
|
|
::
|
2021-09-25 09:50:21 +03:00
|
|
|
=/ tube (convert-tube %json input-mark desk bowl)
|
2020-09-03 07:47:34 +03:00
|
|
|
?> ?=(^ body.request.inbound-request)
|
2023-06-30 22:25:19 +03:00
|
|
|
=/ body=json (need (de:json:html q.u.body.request.inbound-request))
|
2021-07-19 15:17:55 +03:00
|
|
|
=/ input=vase (slop !>(~) (tube !>(body)))
|
2021-07-21 11:56:03 +03:00
|
|
|
=/ boc bec
|
2022-03-16 23:10:31 +03:00
|
|
|
=/ =start-args:spider [~ `tid boc(q desk, r da+now.bowl) thread input]
|
2021-07-19 15:17:55 +03:00
|
|
|
(handle-start-thread start-args)
|
2020-09-03 07:47:34 +03:00
|
|
|
::
|
2019-11-16 14:25:30 +03:00
|
|
|
++ on-poke-input
|
|
|
|
|= input
|
|
|
|
=/ yarn (~(got by tid.state) tid)
|
|
|
|
(take-input yarn ~ %poke cage)
|
2019-09-26 07:12:58 +03:00
|
|
|
::
|
2019-11-07 09:19:32 +03:00
|
|
|
++ on-watch
|
2019-11-16 14:25:30 +03:00
|
|
|
|= [=tid =path]
|
|
|
|
(take-input (~(got by tid.state) tid) ~ %watch path)
|
2019-10-11 01:30:24 +03:00
|
|
|
::
|
2019-11-10 06:09:02 +03:00
|
|
|
++ on-watch-result
|
2019-11-16 14:25:30 +03:00
|
|
|
|= =tid
|
2019-11-10 06:09:02 +03:00
|
|
|
^- (quip card ^state)
|
|
|
|
`state
|
|
|
|
::
|
2019-09-26 07:12:58 +03:00
|
|
|
++ handle-sign
|
2021-06-14 22:28:23 +03:00
|
|
|
~/ %handle-sign
|
2019-11-16 14:25:30 +03:00
|
|
|
|= [=tid =wire =sign-arvo]
|
|
|
|
=/ yarn (~(get by tid.state) tid)
|
|
|
|
?~ yarn
|
|
|
|
%- (slog leaf+"spider got sign for non-existent {<tid>}" ~)
|
2019-11-10 10:27:07 +03:00
|
|
|
`state
|
2019-11-16 14:25:30 +03:00
|
|
|
(take-input u.yarn ~ %sign wire sign-arvo)
|
2019-09-26 07:12:58 +03:00
|
|
|
::
|
2019-11-07 09:19:32 +03:00
|
|
|
++ on-agent
|
2019-11-19 07:36:21 +03:00
|
|
|
|= [=tid =wire =sign:agent:gall]
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ yarn (~(get by tid.state) tid)
|
|
|
|
?~ yarn
|
|
|
|
%- (slog leaf+"spider got agent for non-existent {<tid>}" ~)
|
2019-11-10 10:27:07 +03:00
|
|
|
`state
|
2019-11-16 14:25:30 +03:00
|
|
|
(take-input u.yarn ~ %agent wire sign)
|
2019-09-29 07:44:31 +03:00
|
|
|
::
|
2019-11-16 14:25:30 +03:00
|
|
|
++ handle-start-thread
|
2021-06-14 22:28:23 +03:00
|
|
|
~/ %handle-start-thread
|
2021-07-19 15:17:55 +03:00
|
|
|
|= [parent-tid=(unit tid) use=(unit tid) =beak file=term =vase]
|
2022-08-30 07:09:08 +03:00
|
|
|
(prep-thread parent-tid use beak %| file vase)
|
|
|
|
::
|
|
|
|
++ handle-inline-thread
|
|
|
|
~/ %handle-inline-thread
|
khan: support inline threads
This allows you to pass a thread directly into khan, instead of passing
a filename. This has several implications:
- The friction for using threads from an app is significantly lower.
Consider:
=/ shed
=/ m (strand ,vase)
;< ~ bind:m (poke:strandio [our %hood] %helm-hi !>('hi'))
;< ~ bind:m (poke:strandio [our %hood] %helm-hi !>('there'))
(pure:m !>('product'))
[%pass /wire %arvo %k %lard %base shed]
- These threads close over their subject, so you don't need to parse
arguments out from a vase -- you can just refer to them. The produced
value must still be a vase.
++ hi-ship
|= [=ship msg1=@t msg2=@t]
=/ shed
=/ m (strand ,vase)
;< ~ bind:m (poke:strandio [ship %hood] %helm-hi !>(msg1))
;< ~ bind:m (poke:strandio [ship %hood] %helm-hi !>(msg2))
(pure:m !>('product'))
[%pass /wire %arvo %k %lard %base shed]
- Inline threads can be added to the dojo, though this PR does not add
any sugar for this.
=strandio -build-file %/lib/strandio/hoon
=sh |= message=@t
=/ m (strand:rand ,vase)
;< ~ bind:m (poke:strandio [our %hood] %helm-hi !>('hi'))
;< ~ bind:m (poke:strandio [our %hood] %helm-hi !>(message))
(pure:m !>('product'))
|pass [%k %lard %base (sh 'the message')]
Implementation notes:
- Review the commits separately: the first is small and implements the
real feature. The second moves the strand types into lull so khan can
refer to them.
- In lull, I wanted to put +rand inside +khan, but this fails to that
issue that puts the compiler in a loop. +rand depends on +gall, which
depends on +sign-arvo, which depends on +khan. If +rand is in +khan,
this spins the compiler. The usual solution is to either move
everything into the same battery (very ugly here) or break the
recursion (which we do here).
2022-08-30 07:35:14 +03:00
|
|
|
|= [parent-tid=(unit tid) use=(unit tid) =beak =shed:khan]
|
|
|
|
(prep-thread parent-tid use beak %& shed)
|
2022-08-30 07:09:08 +03:00
|
|
|
::
|
|
|
|
++ prep-thread
|
|
|
|
|= $: parent-tid=(unit tid) use=(unit tid) =beak
|
khan: support inline threads
This allows you to pass a thread directly into khan, instead of passing
a filename. This has several implications:
- The friction for using threads from an app is significantly lower.
Consider:
=/ shed
=/ m (strand ,vase)
;< ~ bind:m (poke:strandio [our %hood] %helm-hi !>('hi'))
;< ~ bind:m (poke:strandio [our %hood] %helm-hi !>('there'))
(pure:m !>('product'))
[%pass /wire %arvo %k %lard %base shed]
- These threads close over their subject, so you don't need to parse
arguments out from a vase -- you can just refer to them. The produced
value must still be a vase.
++ hi-ship
|= [=ship msg1=@t msg2=@t]
=/ shed
=/ m (strand ,vase)
;< ~ bind:m (poke:strandio [ship %hood] %helm-hi !>(msg1))
;< ~ bind:m (poke:strandio [ship %hood] %helm-hi !>(msg2))
(pure:m !>('product'))
[%pass /wire %arvo %k %lard %base shed]
- Inline threads can be added to the dojo, though this PR does not add
any sugar for this.
=strandio -build-file %/lib/strandio/hoon
=sh |= message=@t
=/ m (strand:rand ,vase)
;< ~ bind:m (poke:strandio [our %hood] %helm-hi !>('hi'))
;< ~ bind:m (poke:strandio [our %hood] %helm-hi !>(message))
(pure:m !>('product'))
|pass [%k %lard %base (sh 'the message')]
Implementation notes:
- Review the commits separately: the first is small and implements the
real feature. The second moves the strand types into lull so khan can
refer to them.
- In lull, I wanted to put +rand inside +khan, but this fails to that
issue that puts the compiler in a loop. +rand depends on +gall, which
depends on +sign-arvo, which depends on +khan. If +rand is in +khan,
this spins the compiler. The usual solution is to either move
everything into the same battery (very ugly here) or break the
recursion (which we do here).
2022-08-30 07:35:14 +03:00
|
|
|
source=(each shed:khan [file=term =vase])
|
2022-08-30 07:09:08 +03:00
|
|
|
==
|
2019-09-26 07:12:58 +03:00
|
|
|
^- (quip card ^state)
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ parent-yarn=yarn
|
|
|
|
?~ parent-tid
|
2019-11-10 10:27:07 +03:00
|
|
|
/
|
2019-11-16 14:25:30 +03:00
|
|
|
(~(got by tid.state) u.parent-tid)
|
2022-08-30 07:09:08 +03:00
|
|
|
=/ new-tid
|
|
|
|
?^ use
|
|
|
|
u.use
|
|
|
|
%- new-thread-id
|
|
|
|
?- -.source
|
|
|
|
%& (cat 3 'inline-' q.beak)
|
|
|
|
%| file.p.source
|
|
|
|
==
|
|
|
|
::
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ =yarn (snoc parent-yarn new-tid)
|
2019-11-10 10:27:07 +03:00
|
|
|
::
|
2022-04-23 03:55:42 +03:00
|
|
|
?: (~(has of running.state) yarn)
|
2019-11-16 14:25:30 +03:00
|
|
|
~| [%already-started yarn]
|
2019-09-26 07:12:58 +03:00
|
|
|
!!
|
2019-11-16 14:25:30 +03:00
|
|
|
?: (~(has by starting.state) yarn)
|
|
|
|
~| [%already-starting yarn]
|
2019-11-10 06:09:02 +03:00
|
|
|
!!
|
2019-11-12 08:36:32 +03:00
|
|
|
::
|
2021-09-29 02:57:23 +03:00
|
|
|
=? serving.state !(~(has by serving.state) new-tid)
|
|
|
|
(~(put by serving.state) new-tid [~ %noun q.beak])
|
|
|
|
::
|
2022-08-30 07:09:08 +03:00
|
|
|
=. tid.state (~(put by tid.state) new-tid yarn)
|
|
|
|
?- -.source
|
2022-10-27 08:09:53 +03:00
|
|
|
%& (begin-shed yarn p.source)
|
2022-08-30 07:09:08 +03:00
|
|
|
%|
|
|
|
|
=. starting.state (~(put by starting.state) yarn [%build vase.p.source])
|
|
|
|
=/ pax=path
|
|
|
|
~| no-file-for-thread+file.p.source
|
|
|
|
(need (get-fit:clay beak %ted file.p.source))
|
|
|
|
:_ state
|
|
|
|
:_ ~
|
|
|
|
:+ %pass /build/[new-tid]
|
|
|
|
[%arvo %c %warp p.beak q.beak ~ %sing %a r.beak pax]
|
2021-09-27 01:30:12 +03:00
|
|
|
==
|
2019-09-26 22:00:11 +03:00
|
|
|
::
|
|
|
|
++ handle-build
|
2021-06-14 22:28:23 +03:00
|
|
|
~/ %handle-build
|
2019-11-16 14:25:30 +03:00
|
|
|
|= [=tid =sign-arvo]
|
2019-09-26 22:00:11 +03:00
|
|
|
^- (quip card ^state)
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ =yarn (~(got by tid.state) tid)
|
2019-11-16 04:20:56 +03:00
|
|
|
=. starting.state
|
2019-11-16 14:25:30 +03:00
|
|
|
(~(jab by starting.state) yarn |=([=trying =vase] [%none vase]))
|
2020-04-21 08:05:05 +03:00
|
|
|
~| sign+[- +<]:sign-arvo
|
2020-12-08 03:22:26 +03:00
|
|
|
?> ?=([?(%behn %clay) %writ *] sign-arvo)
|
2020-04-21 08:05:05 +03:00
|
|
|
=/ =riot:clay p.sign-arvo
|
|
|
|
?~ riot
|
|
|
|
(thread-fail-not-running tid %build-thread-error *tang)
|
|
|
|
?. ?=(%vase p.r.u.riot)
|
|
|
|
(thread-fail-not-running tid %build-thread-strange >[p q]:u.riot< ~)
|
|
|
|
=/ maybe-thread (mule |.(!<(thread !<(vase q.r.u.riot))))
|
2019-11-16 14:25:30 +03:00
|
|
|
?: ?=(%| -.maybe-thread)
|
|
|
|
(thread-fail-not-running tid %thread-not-thread ~)
|
2022-10-27 08:09:53 +03:00
|
|
|
(slam-thread yarn p.maybe-thread)
|
2019-11-16 14:25:30 +03:00
|
|
|
::
|
2022-10-27 08:09:53 +03:00
|
|
|
++ slam-thread
|
|
|
|
~/ %slam-thread
|
2019-11-16 14:25:30 +03:00
|
|
|
|= [=yarn =thread]
|
2019-09-26 22:00:11 +03:00
|
|
|
^- (quip card ^state)
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ =vase vase:(~(got by starting.state) yarn)
|
|
|
|
=/ res (mule |.((thread vase)))
|
2019-11-16 04:20:56 +03:00
|
|
|
?: ?=(%| -.res)
|
2019-11-16 14:25:30 +03:00
|
|
|
(thread-fail-not-running (yarn-to-tid yarn) %false-start p.res)
|
2022-08-30 07:09:08 +03:00
|
|
|
=. starting.state (~(del by starting.state) yarn)
|
2022-10-27 08:09:53 +03:00
|
|
|
(begin-shed yarn p.res)
|
2022-08-30 07:09:08 +03:00
|
|
|
::
|
2022-10-27 08:09:53 +03:00
|
|
|
++ begin-shed
|
khan: support inline threads
This allows you to pass a thread directly into khan, instead of passing
a filename. This has several implications:
- The friction for using threads from an app is significantly lower.
Consider:
=/ shed
=/ m (strand ,vase)
;< ~ bind:m (poke:strandio [our %hood] %helm-hi !>('hi'))
;< ~ bind:m (poke:strandio [our %hood] %helm-hi !>('there'))
(pure:m !>('product'))
[%pass /wire %arvo %k %lard %base shed]
- These threads close over their subject, so you don't need to parse
arguments out from a vase -- you can just refer to them. The produced
value must still be a vase.
++ hi-ship
|= [=ship msg1=@t msg2=@t]
=/ shed
=/ m (strand ,vase)
;< ~ bind:m (poke:strandio [ship %hood] %helm-hi !>(msg1))
;< ~ bind:m (poke:strandio [ship %hood] %helm-hi !>(msg2))
(pure:m !>('product'))
[%pass /wire %arvo %k %lard %base shed]
- Inline threads can be added to the dojo, though this PR does not add
any sugar for this.
=strandio -build-file %/lib/strandio/hoon
=sh |= message=@t
=/ m (strand:rand ,vase)
;< ~ bind:m (poke:strandio [our %hood] %helm-hi !>('hi'))
;< ~ bind:m (poke:strandio [our %hood] %helm-hi !>(message))
(pure:m !>('product'))
|pass [%k %lard %base (sh 'the message')]
Implementation notes:
- Review the commits separately: the first is small and implements the
real feature. The second moves the strand types into lull so khan can
refer to them.
- In lull, I wanted to put +rand inside +khan, but this fails to that
issue that puts the compiler in a loop. +rand depends on +gall, which
depends on +sign-arvo, which depends on +khan. If +rand is in +khan,
this spins the compiler. The usual solution is to either move
everything into the same battery (very ugly here) or break the
recursion (which we do here).
2022-08-30 07:35:14 +03:00
|
|
|
|= [=yarn =shed:khan]
|
2022-08-30 07:09:08 +03:00
|
|
|
?< (~(has of running.state) yarn)
|
|
|
|
=/ m (strand ,vase)
|
khan: support inline threads
This allows you to pass a thread directly into khan, instead of passing
a filename. This has several implications:
- The friction for using threads from an app is significantly lower.
Consider:
=/ shed
=/ m (strand ,vase)
;< ~ bind:m (poke:strandio [our %hood] %helm-hi !>('hi'))
;< ~ bind:m (poke:strandio [our %hood] %helm-hi !>('there'))
(pure:m !>('product'))
[%pass /wire %arvo %k %lard %base shed]
- These threads close over their subject, so you don't need to parse
arguments out from a vase -- you can just refer to them. The produced
value must still be a vase.
++ hi-ship
|= [=ship msg1=@t msg2=@t]
=/ shed
=/ m (strand ,vase)
;< ~ bind:m (poke:strandio [ship %hood] %helm-hi !>(msg1))
;< ~ bind:m (poke:strandio [ship %hood] %helm-hi !>(msg2))
(pure:m !>('product'))
[%pass /wire %arvo %k %lard %base shed]
- Inline threads can be added to the dojo, though this PR does not add
any sugar for this.
=strandio -build-file %/lib/strandio/hoon
=sh |= message=@t
=/ m (strand:rand ,vase)
;< ~ bind:m (poke:strandio [our %hood] %helm-hi !>('hi'))
;< ~ bind:m (poke:strandio [our %hood] %helm-hi !>(message))
(pure:m !>('product'))
|pass [%k %lard %base (sh 'the message')]
Implementation notes:
- Review the commits separately: the first is small and implements the
real feature. The second moves the strand types into lull so khan can
refer to them.
- In lull, I wanted to put +rand inside +khan, but this fails to that
issue that puts the compiler in a loop. +rand depends on +gall, which
depends on +sign-arvo, which depends on +khan. If +rand is in +khan,
this spins the compiler. The usual solution is to either move
everything into the same battery (very ugly here) or break the
recursion (which we do here).
2022-08-30 07:35:14 +03:00
|
|
|
=/ =eval-form:eval:m (from-form:eval:m shed)
|
2022-08-30 07:09:08 +03:00
|
|
|
=. running.state (~(put of running.state) yarn eval-form)
|
2019-11-16 14:25:30 +03:00
|
|
|
(take-input yarn ~)
|
2019-09-26 07:12:58 +03:00
|
|
|
::
|
2019-11-16 14:25:30 +03:00
|
|
|
++ handle-stop-thread
|
|
|
|
|= [=tid nice=?]
|
2019-09-29 07:44:31 +03:00
|
|
|
^- (quip card ^state)
|
2020-11-21 01:22:49 +03:00
|
|
|
=/ yarn=(unit yarn) (~(get by tid.state) tid)
|
|
|
|
?~ yarn
|
|
|
|
~& %stopping-nonexistent-thread
|
|
|
|
[~ state]
|
2022-04-23 03:55:42 +03:00
|
|
|
?: (~(has of running.state) u.yarn)
|
2023-04-03 10:18:51 +03:00
|
|
|
?. nice
|
|
|
|
(thread-fail u.yarn %cancelled ~)
|
2023-04-27 14:55:06 +03:00
|
|
|
=^ done-cards state (thread-done u.yarn *vase silent=%.n)
|
|
|
|
[done-cards state]
|
2020-11-21 01:22:49 +03:00
|
|
|
?: (~(has by starting.state) u.yarn)
|
2019-11-16 14:25:30 +03:00
|
|
|
(thread-fail-not-running tid %stopped-before-started ~)
|
2020-11-21 01:22:49 +03:00
|
|
|
~& [%thread-not-started u.yarn]
|
2019-12-01 06:38:43 +03:00
|
|
|
?: nice
|
2023-04-27 14:55:06 +03:00
|
|
|
(thread-done u.yarn *vase silent=%.y)
|
2020-11-21 01:22:49 +03:00
|
|
|
(thread-fail u.yarn %cancelled ~)
|
2019-09-29 07:44:31 +03:00
|
|
|
::
|
2019-09-26 07:12:58 +03:00
|
|
|
++ take-input
|
2021-06-14 22:28:23 +03:00
|
|
|
~/ %take-input
|
2019-11-16 14:25:30 +03:00
|
|
|
|= [=yarn input=(unit input:strand)]
|
2019-09-26 07:12:58 +03:00
|
|
|
^- (quip card ^state)
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ m (strand ,vase)
|
2022-04-23 03:55:42 +03:00
|
|
|
?. (~(has of running.state) yarn)
|
2021-09-27 09:43:34 +03:00
|
|
|
%- (slog leaf+"spider got input for non-existent {<yarn>}" ~)
|
2019-10-01 06:53:02 +03:00
|
|
|
`state
|
2019-09-26 07:12:58 +03:00
|
|
|
=/ =eval-form:eval:m
|
2022-04-23 03:55:42 +03:00
|
|
|
(need fil:(~(dip of running.state) yarn))
|
2019-09-26 07:12:58 +03:00
|
|
|
=| cards=(list card)
|
|
|
|
|- ^- (quip card ^state)
|
|
|
|
=^ r=[cards=(list card) =eval-result:eval:m] eval-form
|
|
|
|
=/ out
|
|
|
|
%- mule |.
|
2019-11-16 14:25:30 +03:00
|
|
|
(take:eval:m eval-form (convert-bowl yarn bowl) input)
|
2019-09-26 07:12:58 +03:00
|
|
|
?- -.out
|
|
|
|
%& p.out
|
|
|
|
%| [[~ [%fail %crash p.out]] eval-form]
|
|
|
|
==
|
2022-04-23 03:55:42 +03:00
|
|
|
=. running.state (~(put of running.state) yarn eval-form)
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ =tid (yarn-to-tid yarn)
|
2023-04-04 15:44:36 +03:00
|
|
|
=^ new-cards state
|
|
|
|
^- [(list card) _state]
|
|
|
|
%+ roll cards.r
|
|
|
|
|= [=card cards=(list card) s=_state]
|
2023-04-27 14:55:06 +03:00
|
|
|
:_ =? scrying.s ?=([%pass ^ %arvo %a %keen @ *] card)
|
|
|
|
(~(put ju scrying.s) tid [&2 &6 |6]:card)
|
2023-04-04 15:44:36 +03:00
|
|
|
s
|
|
|
|
:_ cards
|
2019-09-26 07:12:58 +03:00
|
|
|
^- ^card
|
|
|
|
?+ card card
|
2019-11-16 14:25:30 +03:00
|
|
|
[%pass * *] [%pass [%thread tid p.card] q.card]
|
2019-12-22 23:12:28 +03:00
|
|
|
[%give ?(%fact %kick) *]
|
|
|
|
=- card(paths.p -)
|
|
|
|
%+ turn paths.p.card
|
|
|
|
|= =path
|
|
|
|
^- ^path
|
|
|
|
[%thread tid path]
|
2019-09-26 07:12:58 +03:00
|
|
|
==
|
2023-04-04 15:44:36 +03:00
|
|
|
=. cards (weld cards (flop new-cards))
|
2019-09-26 07:12:58 +03:00
|
|
|
=^ final-cards=(list card) state
|
|
|
|
?- -.eval-result.r
|
|
|
|
%next `state
|
2019-11-16 14:25:30 +03:00
|
|
|
%fail (thread-fail yarn err.eval-result.r)
|
2023-04-27 14:55:06 +03:00
|
|
|
%done (thread-done yarn value.eval-result.r silent=%.y)
|
2019-09-26 07:12:58 +03:00
|
|
|
==
|
|
|
|
[(weld cards final-cards) state]
|
|
|
|
::
|
2019-11-16 14:25:30 +03:00
|
|
|
++ thread-fail-not-running
|
|
|
|
|= [=tid =term =tang]
|
2020-06-18 06:31:37 +03:00
|
|
|
^- (quip card ^state)
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ =yarn (~(got by tid.state) tid)
|
2020-06-18 06:31:37 +03:00
|
|
|
:_ state(starting (~(del by starting.state) yarn))
|
|
|
|
=/ moz (thread-say-fail tid term tang)
|
|
|
|
?. ?=([~ %build *] (~(get by starting.state) yarn))
|
|
|
|
moz
|
2021-07-15 09:51:03 +03:00
|
|
|
:_(moz [%pass /build/[tid] %arvo %c %warp our.bowl %base ~])
|
2019-11-16 04:20:56 +03:00
|
|
|
::
|
2019-11-16 14:25:30 +03:00
|
|
|
++ thread-say-fail
|
|
|
|
|= [=tid =term =tang]
|
2019-11-16 04:20:56 +03:00
|
|
|
^- (list card)
|
2019-12-22 23:12:28 +03:00
|
|
|
:~ [%give %fact ~[/thread-result/[tid]] %thread-fail !>([term tang])]
|
|
|
|
[%give %kick ~[/thread-result/[tid]] ~]
|
2019-11-16 04:20:56 +03:00
|
|
|
==
|
2023-04-03 10:18:51 +03:00
|
|
|
::
|
|
|
|
++ cancel-scry
|
2023-04-19 12:03:11 +03:00
|
|
|
|= [=tid silent=?]
|
2023-04-03 10:18:51 +03:00
|
|
|
^- (quip card _state)
|
2023-04-27 14:55:06 +03:00
|
|
|
?~ scrying=(~(get ju scrying.state) tid)
|
2023-04-03 10:18:51 +03:00
|
|
|
`state
|
2023-04-27 14:55:06 +03:00
|
|
|
:_ state(scrying (~(del by scrying.state) tid))
|
2023-04-19 12:03:11 +03:00
|
|
|
?: silent ~
|
2023-04-27 14:55:06 +03:00
|
|
|
%- ~(rep in `(set [wire ship path])`scrying)
|
|
|
|
|= [[=wire =ship =path] cards=(list card)]
|
|
|
|
%- (slog leaf+"cancelling {<tid>}: [{<[wire ship path]>}]" ~)
|
|
|
|
:_ cards
|
|
|
|
[%pass (welp /thread/[tid] wire) %arvo %a %yawn ship path]
|
2023-04-03 10:18:51 +03:00
|
|
|
::
|
2020-09-03 07:47:34 +03:00
|
|
|
++ thread-http-fail
|
|
|
|
|= [=tid =term =tang]
|
|
|
|
^- (quip card ^state)
|
|
|
|
=- (fall - `state)
|
2021-09-26 02:45:05 +03:00
|
|
|
%+ bind
|
2020-09-03 07:47:34 +03:00
|
|
|
(~(get by serving.state) tid)
|
2021-09-26 02:45:05 +03:00
|
|
|
|= [eyre-id=(unit @ta) output=mark =desk]
|
2020-09-03 07:47:34 +03:00
|
|
|
:_ state(serving (~(del by serving.state) tid))
|
2021-09-27 23:51:33 +03:00
|
|
|
?~ eyre-id
|
2021-09-28 05:09:35 +03:00
|
|
|
~
|
2021-09-27 23:51:33 +03:00
|
|
|
%+ give-simple-payload:app:server u.eyre-id
|
2020-09-03 07:47:34 +03:00
|
|
|
^- simple-payload:http
|
2020-09-11 06:08:16 +03:00
|
|
|
?. ?=(http-error:spider term)
|
2023-06-02 20:05:16 +03:00
|
|
|
%- (slog tang)
|
|
|
|
=/ tube (convert-tube %tang %json desk bowl)
|
2023-06-06 20:01:43 +03:00
|
|
|
:- [500 [['content-type' 'application/json'] ~]]
|
2023-06-09 20:45:39 +03:00
|
|
|
=- `(as-octs:mimes:html (en:json:html -))
|
2023-06-02 20:05:16 +03:00
|
|
|
o/(malt `(list [key=@t json])`[term+s/term tang+!<(json (tube !>(tang))) ~])
|
|
|
|
:_ ~ :_ ~
|
2020-09-11 06:08:16 +03:00
|
|
|
?- term
|
|
|
|
%bad-request 400
|
|
|
|
%forbidden 403
|
|
|
|
%nonexistent 404
|
|
|
|
%offline 504
|
|
|
|
==
|
2019-11-16 04:20:56 +03:00
|
|
|
::
|
2019-11-16 14:25:30 +03:00
|
|
|
++ thread-fail
|
|
|
|
|= [=yarn =term =tang]
|
2019-09-26 07:12:58 +03:00
|
|
|
^- (quip card ^state)
|
2020-12-10 22:55:14 +03:00
|
|
|
::%- (slog leaf+"strand {<yarn>} failed" leaf+<term> tang)
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ =tid (yarn-to-tid yarn)
|
|
|
|
=/ fail-cards (thread-say-fail tid term tang)
|
2020-09-03 07:47:34 +03:00
|
|
|
=^ http-cards state (thread-http-fail tid term tang)
|
2023-04-27 14:55:06 +03:00
|
|
|
=^ scry-card state (cancel-scry tid silent=%.n)
|
2023-06-02 20:05:16 +03:00
|
|
|
=^ cards state (thread-clean yarn)
|
2023-04-03 10:18:51 +03:00
|
|
|
:_ state
|
2023-04-03 10:40:56 +03:00
|
|
|
:(weld fail-cards cards http-cards scry-card)
|
2020-09-03 07:47:34 +03:00
|
|
|
::
|
|
|
|
++ thread-http-response
|
|
|
|
|= [=tid =vase]
|
|
|
|
^- (quip card ^state)
|
|
|
|
=- (fall - `state)
|
2021-09-26 02:45:05 +03:00
|
|
|
%+ bind
|
2020-09-03 07:47:34 +03:00
|
|
|
(~(get by serving.state) tid)
|
2021-09-25 09:50:21 +03:00
|
|
|
|= [eyre-id=(unit @ta) output=mark =desk]
|
2021-09-27 23:51:33 +03:00
|
|
|
?~ eyre-id
|
|
|
|
`state
|
2021-09-25 09:50:21 +03:00
|
|
|
=/ tube (convert-tube output %json desk bowl)
|
2021-09-26 02:45:05 +03:00
|
|
|
:_ state(serving (~(del by serving.state) tid))
|
2021-09-27 23:51:33 +03:00
|
|
|
%+ give-simple-payload:app:server u.eyre-id
|
2021-09-26 02:45:05 +03:00
|
|
|
(json-response:gen:server !<(json (tube vase)))
|
2019-09-26 07:12:58 +03:00
|
|
|
::
|
2019-11-16 14:25:30 +03:00
|
|
|
++ thread-done
|
2023-04-27 14:55:06 +03:00
|
|
|
|= [=yarn =vase silent=?]
|
2019-09-26 07:12:58 +03:00
|
|
|
^- (quip card ^state)
|
2019-11-16 14:25:30 +03:00
|
|
|
:: %- (slog leaf+"strand {<yarn>} finished" (sell vase) ~)
|
|
|
|
=/ =tid (yarn-to-tid yarn)
|
2019-11-10 06:09:02 +03:00
|
|
|
=/ done-cards=(list card)
|
2019-12-22 23:12:28 +03:00
|
|
|
:~ [%give %fact ~[/thread-result/[tid]] %thread-done vase]
|
|
|
|
[%give %kick ~[/thread-result/[tid]] ~]
|
2019-11-10 06:09:02 +03:00
|
|
|
==
|
2020-09-03 07:47:34 +03:00
|
|
|
=^ http-cards state
|
|
|
|
(thread-http-response tid vase)
|
2023-04-27 14:55:06 +03:00
|
|
|
=^ scry-card state (cancel-scry tid silent)
|
|
|
|
=^ cards state (thread-clean yarn)
|
2023-04-03 10:40:56 +03:00
|
|
|
[:(weld done-cards cards http-cards scry-card) state]
|
2019-10-01 06:53:02 +03:00
|
|
|
::
|
2019-11-16 14:25:30 +03:00
|
|
|
++ thread-clean
|
|
|
|
|= =yarn
|
2019-10-01 06:53:02 +03:00
|
|
|
^- (quip card ^state)
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ children=(list ^yarn)
|
2022-04-06 10:19:38 +03:00
|
|
|
%+ turn
|
2022-04-23 03:55:42 +03:00
|
|
|
~(tap of (~(dip of running.state) yarn))
|
2022-04-06 10:19:38 +03:00
|
|
|
|= [child=^yarn *]
|
|
|
|
(welp yarn child)
|
2019-11-10 10:27:07 +03:00
|
|
|
|- ^- (quip card ^state)
|
|
|
|
?~ children
|
|
|
|
`state
|
|
|
|
=^ cards-children state $(children t.children)
|
|
|
|
=^ cards-our state
|
2019-11-16 14:25:30 +03:00
|
|
|
=/ =^yarn i.children
|
|
|
|
=/ =tid (yarn-to-tid yarn)
|
2022-04-23 03:55:42 +03:00
|
|
|
=: running.state (~(lop of running.state) yarn)
|
2019-11-16 14:25:30 +03:00
|
|
|
tid.state (~(del by tid.state) tid)
|
2022-04-06 10:19:38 +03:00
|
|
|
serving.state (~(del by serving.state) (yarn-to-tid yarn))
|
2019-10-01 06:53:02 +03:00
|
|
|
==
|
2019-11-10 10:27:07 +03:00
|
|
|
:_ state
|
|
|
|
%+ murn ~(tap by wex.bowl)
|
|
|
|
|= [[=wire =ship =term] [acked=? =path]]
|
|
|
|
^- (unit card)
|
2019-11-16 14:25:30 +03:00
|
|
|
?. ?& ?=([%thread @ *] wire)
|
|
|
|
=(tid i.t.wire)
|
2019-11-10 10:27:07 +03:00
|
|
|
==
|
|
|
|
~
|
|
|
|
`[%pass wire %agent [ship term] %leave ~]
|
|
|
|
[(welp cards-children cards-our) state]
|
|
|
|
::
|
|
|
|
++ convert-bowl
|
2019-11-19 07:36:21 +03:00
|
|
|
|= [=yarn =bowl:gall]
|
2019-11-10 10:27:07 +03:00
|
|
|
^- bowl:spider
|
|
|
|
:* our.bowl
|
2021-09-26 02:45:05 +03:00
|
|
|
src.bowl
|
2019-11-16 14:25:30 +03:00
|
|
|
(yarn-to-tid yarn)
|
|
|
|
(yarn-to-parent yarn)
|
2019-11-10 10:27:07 +03:00
|
|
|
wex.bowl
|
|
|
|
sup.bowl
|
|
|
|
eny.bowl
|
|
|
|
now.bowl
|
2021-09-25 09:50:21 +03:00
|
|
|
(yarn-to-byk yarn bowl)
|
2019-11-10 10:27:07 +03:00
|
|
|
==
|
|
|
|
::
|
2019-11-16 14:25:30 +03:00
|
|
|
++ yarn-to-tid
|
|
|
|
|= =yarn
|
|
|
|
^- tid
|
|
|
|
=/ nary (flop yarn)
|
|
|
|
?> ?=([@ *] nary)
|
|
|
|
i.nary
|
|
|
|
::
|
|
|
|
++ yarn-to-parent
|
|
|
|
|= =yarn
|
|
|
|
^- (unit tid)
|
|
|
|
=/ nary (flop yarn)
|
|
|
|
?> ?=([@ *] nary)
|
|
|
|
?~ t.nary
|
2019-10-01 06:53:02 +03:00
|
|
|
~
|
2019-11-16 14:25:30 +03:00
|
|
|
`i.t.nary
|
2019-11-10 10:27:07 +03:00
|
|
|
::
|
2021-09-25 09:50:21 +03:00
|
|
|
++ yarn-to-byk
|
2021-09-26 02:45:05 +03:00
|
|
|
|= [=yarn =bowl:gall]
|
2021-09-28 05:09:35 +03:00
|
|
|
=/ [* * =desk]
|
|
|
|
~| "no desk associated with {<tid>}"
|
|
|
|
%- ~(got by serving.state) (yarn-to-tid yarn)
|
|
|
|
=/ boc bec
|
|
|
|
boc(q desk)
|
2021-09-25 09:50:21 +03:00
|
|
|
::
|
2019-11-10 10:27:07 +03:00
|
|
|
++ clean-state
|
|
|
|
!> ^- clean-slate
|
2023-04-27 14:55:06 +03:00
|
|
|
6+state(running (turn ~(tap of running.state) head))
|
2021-09-25 09:50:21 +03:00
|
|
|
::
|
|
|
|
++ convert-tube
|
2021-09-26 02:45:05 +03:00
|
|
|
|= [from=mark to=mark =desk =bowl:gall]
|
2021-09-25 09:50:21 +03:00
|
|
|
.^
|
|
|
|
tube:clay
|
|
|
|
%cc
|
|
|
|
/(scot %p our.bowl)/[desk]/(scot %da now.bowl)/[from]/[to]
|
|
|
|
==
|
2019-09-26 07:12:58 +03:00
|
|
|
--
|