urbit/pkg/arvo/lib/strandio.hoon

648 lines
15 KiB
Plaintext
Raw Normal View History

2019-11-15 00:31:44 +03:00
/- spider
/+ libstrand=strand
=, strand=strand:libstrand
=, strand-fail=strand-fail:libstrand
2019-09-26 07:12:58 +03:00
|%
2019-09-29 07:44:31 +03:00
++ send-raw-cards
2019-11-19 07:36:21 +03:00
|= cards=(list =card:agent:gall)
=/ m (strand ,~)
2019-09-29 07:44:31 +03:00
^- form:m
|= strand-input:strand
2019-09-29 07:44:31 +03:00
[cards %done ~]
::
2019-09-26 07:12:58 +03:00
++ send-raw-card
2019-11-19 07:36:21 +03:00
|= =card:agent:gall
=/ m (strand ,~)
2019-09-26 07:12:58 +03:00
^- form:m
2019-09-29 07:44:31 +03:00
(send-raw-cards card ~)
::
2019-10-11 01:30:24 +03:00
++ ignore
|= tin=strand-input:strand
2019-10-11 01:30:24 +03:00
`[%fail %ignore ~]
::
2019-09-29 07:44:31 +03:00
++ get-bowl
=/ m (strand ,bowl:strand)
2019-09-29 07:44:31 +03:00
^- form:m
|= tin=strand-input:strand
2019-09-29 07:44:31 +03:00
`[%done bowl.tin]
2019-09-26 07:12:58 +03:00
::
2020-04-19 12:11:01 +03:00
++ get-beak
=/ m (strand ,beak)
^- form:m
|= tin=strand-input:strand
`[%done [our q.byk da+now]:bowl.tin]
::
2019-09-26 07:12:58 +03:00
++ get-time
=/ m (strand ,@da)
2019-09-26 07:12:58 +03:00
^- form:m
|= tin=strand-input:strand
2019-09-26 07:12:58 +03:00
`[%done now.bowl.tin]
::
2019-09-29 07:44:31 +03:00
++ get-our
=/ m (strand ,ship)
2019-09-29 07:44:31 +03:00
^- form:m
|= tin=strand-input:strand
2019-09-29 07:44:31 +03:00
`[%done our.bowl.tin]
::
2019-10-11 01:30:24 +03:00
++ get-entropy
=/ m (strand ,@uvJ)
2019-10-11 01:30:24 +03:00
^- form:m
|= tin=strand-input:strand
2019-10-11 01:30:24 +03:00
`[%done eny.bowl.tin]
::
2019-09-29 07:44:31 +03:00
:: Convert skips to %ignore failures.
::
:: This tells the main loop to try the next handler.
::
++ handle
|* a=mold
=/ m (strand ,a)
2019-09-29 07:44:31 +03:00
|= =form:m
^- form:m
|= tin=strand-input:strand
2019-09-29 07:44:31 +03:00
=/ res (form tin)
=? next.res ?=(%skip -.next.res)
[%fail %ignore ~]
res
::
:: Wait for a poke with a particular mark
::
++ take-poke
2019-09-26 08:43:14 +03:00
|= =mark
=/ m (strand ,vase)
2019-09-26 08:43:14 +03:00
^- form:m
|= tin=strand-input:strand
2019-09-29 07:44:31 +03:00
?+ in.tin `[%skip ~]
2019-09-26 08:43:14 +03:00
~ `[%wait ~]
[~ %poke @ *]
?. =(mark p.cage.u.in.tin)
2019-09-29 07:44:31 +03:00
`[%skip ~]
2019-09-26 08:43:14 +03:00
`[%done q.cage.u.in.tin]
==
::
2019-09-29 07:44:31 +03:00
::
::
++ take-sign-arvo
=/ m (strand ,[wire sign-arvo])
2019-09-26 07:12:58 +03:00
^- form:m
|= tin=strand-input:strand
2019-09-26 07:12:58 +03:00
?+ in.tin `[%skip ~]
~ `[%wait ~]
2019-09-29 07:44:31 +03:00
[~ %sign *]
`[%done [wire sign-arvo]:u.in.tin]
==
::
:: Wait for a subscription update on a wire
::
2019-11-07 09:19:32 +03:00
++ take-fact-prefix
2019-11-06 10:24:41 +03:00
|= =wire
=/ m (strand ,[path cage])
2019-11-06 10:24:41 +03:00
^- form:m
|= tin=strand-input:strand
2019-11-06 10:24:41 +03:00
?+ in.tin `[%skip ~]
~ `[%wait ~]
2019-11-07 09:19:32 +03:00
[~ %agent * %fact *]
?. =(watch+wire (scag +((lent wire)) wire.u.in.tin))
2019-11-06 10:24:41 +03:00
`[%skip ~]
`[%done (slag (lent wire) wire.u.in.tin) cage.sign.u.in.tin]
2019-11-06 10:24:41 +03:00
==
::
:: Wait for a subscription update on a wire
::
2019-11-07 09:19:32 +03:00
++ take-fact
2019-09-29 07:44:31 +03:00
|= =wire
=/ m (strand ,cage)
2019-09-29 07:44:31 +03:00
^- form:m
|= tin=strand-input:strand
2019-09-29 07:44:31 +03:00
?+ in.tin `[%skip ~]
~ `[%wait ~]
2019-11-07 09:19:32 +03:00
[~ %agent * %fact *]
?. =(watch+wire wire.u.in.tin)
2019-09-26 07:12:58 +03:00
`[%skip ~]
`[%done cage.sign.u.in.tin]
2019-09-26 07:12:58 +03:00
==
::
2019-11-06 10:24:41 +03:00
:: Wait for a subscription close
::
2019-11-07 09:19:32 +03:00
++ take-kick
2019-11-06 10:24:41 +03:00
|= =wire
=/ m (strand ,~)
2019-11-06 10:24:41 +03:00
^- form:m
|= tin=strand-input:strand
2019-11-06 10:24:41 +03:00
?+ in.tin `[%skip ~]
~ `[%wait ~]
2019-11-07 09:19:32 +03:00
[~ %agent * %kick *]
?. =(watch+wire wire.u.in.tin)
2019-11-06 10:24:41 +03:00
`[%skip ~]
`[%done ~]
==
::
2019-09-26 07:12:58 +03:00
++ echo
=/ m (strand ,~)
2019-09-26 07:12:58 +03:00
^- form:m
2019-09-29 07:44:31 +03:00
%- (main-loop ,~)
:~ |= ~
^- form:m
;< =vase bind:m ((handle ,vase) (take-poke %echo))
=/ message=tape !<(tape vase)
%- (slog leaf+"{message}..." ~)
;< ~ bind:m (sleep ~s2)
%- (slog leaf+"{message}.." ~)
(pure:m ~)
2019-09-26 08:43:14 +03:00
::
2019-09-29 07:44:31 +03:00
|= ~
^- form:m
;< =vase bind:m ((handle ,vase) (take-poke %over))
%- (slog leaf+"over..." ~)
(pure:m ~)
2019-09-26 08:43:14 +03:00
==
2019-09-26 07:12:58 +03:00
::
2019-11-07 09:19:32 +03:00
++ take-watch
=/ m (strand ,path)
|= tin=strand-input:strand
2019-10-11 01:30:24 +03:00
?+ in.tin `[%skip ~]
~ `[%wait ~]
2019-11-07 09:19:32 +03:00
[~ %watch *]
2019-10-11 01:30:24 +03:00
`[%done path.u.in.tin]
==
::
2019-09-26 07:12:58 +03:00
++ take-wake
2019-10-11 01:30:24 +03:00
|= until=(unit @da)
=/ m (strand ,~)
2019-09-26 07:12:58 +03:00
^- form:m
|= tin=strand-input:strand
2019-09-26 07:12:58 +03:00
?+ in.tin `[%skip ~]
~ `[%wait ~]
[~ %sign [%wait @ ~] %b %wake *]
2019-10-11 01:30:24 +03:00
?. |(?=(~ until) =(`u.until (slaw %da i.t.wire.u.in.tin)))
2019-09-26 07:12:58 +03:00
`[%skip ~]
2019-09-27 20:40:22 +03:00
?~ error.sign-arvo.u.in.tin
`[%done ~]
`[%fail %timer-error u.error.sign-arvo.u.in.tin]
2019-09-26 07:12:58 +03:00
==
::
2019-09-29 07:44:31 +03:00
++ take-poke-ack
|= =wire
=/ m (strand ,~)
2019-09-29 07:44:31 +03:00
^- form:m
|= tin=strand-input:strand
2019-09-29 07:44:31 +03:00
?+ in.tin `[%skip ~]
~ `[%wait ~]
[~ %agent * %poke-ack *]
?. =(wire wire.u.in.tin)
`[%skip ~]
?~ p.sign.u.in.tin
2019-09-29 07:44:31 +03:00
`[%done ~]
`[%fail %poke-fail u.p.sign.u.in.tin]
2019-09-29 07:44:31 +03:00
==
::
2019-11-07 09:19:32 +03:00
++ take-watch-ack
2019-09-29 07:44:31 +03:00
|= =wire
=/ m (strand ,~)
2019-09-29 07:44:31 +03:00
^- form:m
|= tin=strand-input:strand
2019-09-29 07:44:31 +03:00
?+ in.tin `[%skip ~]
~ `[%wait ~]
2019-11-07 09:19:32 +03:00
[~ %agent * %watch-ack *]
?. =(watch+wire wire.u.in.tin)
2019-09-29 07:44:31 +03:00
`[%skip ~]
?~ p.sign.u.in.tin
2019-09-29 07:44:31 +03:00
`[%done ~]
`[%fail %watch-ack-fail u.p.sign.u.in.tin]
2019-09-29 07:44:31 +03:00
==
::
++ poke
|= [=dock =cage]
=/ m (strand ,~)
2019-09-29 07:44:31 +03:00
^- form:m
2019-11-19 07:36:21 +03:00
=/ =card:agent:gall [%pass /poke %agent dock %poke cage]
2019-09-29 07:44:31 +03:00
;< ~ bind:m (send-raw-card card)
(take-poke-ack /poke)
::
++ poke-our
|= [=term =cage]
=/ m (strand ,~)
2019-09-29 07:44:31 +03:00
^- form:m
;< our=@p bind:m get-our
(poke [our term] cage)
::
2019-11-07 09:19:32 +03:00
++ watch
2019-09-29 07:44:31 +03:00
|= [=wire =dock =path]
=/ m (strand ,~)
2019-09-29 07:44:31 +03:00
^- form:m
2019-11-19 07:36:21 +03:00
=/ =card:agent:gall [%pass watch+wire %agent dock %watch path]
2019-09-29 07:44:31 +03:00
;< ~ bind:m (send-raw-card card)
2019-11-07 09:19:32 +03:00
(take-watch-ack wire)
2019-09-29 07:44:31 +03:00
::
2019-11-07 09:19:32 +03:00
++ watch-our
2019-09-29 07:44:31 +03:00
|= [=wire =term =path]
=/ m (strand ,~)
2019-09-29 07:44:31 +03:00
^- form:m
;< our=@p bind:m get-our
2019-11-07 09:19:32 +03:00
(watch wire [our term] path)
2019-09-29 07:44:31 +03:00
::
2019-11-07 09:19:32 +03:00
++ leave
2019-09-29 07:44:31 +03:00
|= [=wire =dock]
=/ m (strand ,~)
2019-09-29 07:44:31 +03:00
^- form:m
2019-11-19 07:36:21 +03:00
=/ =card:agent:gall [%pass watch+wire %agent dock %leave ~]
2019-09-29 07:44:31 +03:00
(send-raw-card card)
::
2019-11-07 09:19:32 +03:00
++ leave-our
2019-09-29 07:44:31 +03:00
|= [=wire =term]
=/ m (strand ,~)
2019-09-29 07:44:31 +03:00
^- form:m
;< our=@p bind:m get-our
2019-11-07 09:19:32 +03:00
(leave wire [our term])
2019-09-29 07:44:31 +03:00
::
2019-11-07 09:19:32 +03:00
++ rewatch
2019-11-06 10:24:41 +03:00
|= [=wire =dock =path]
=/ m (strand ,~)
2019-11-07 09:19:32 +03:00
;< ~ bind:m ((handle ,~) (take-kick wire))
;< ~ bind:m (flog-text "rewatching {<dock>} {<path>}")
;< ~ bind:m (watch wire dock path)
2019-11-06 10:24:41 +03:00
(pure:m ~)
::
2019-09-26 07:12:58 +03:00
++ wait
|= until=@da
=/ m (strand ,~)
2019-09-26 07:12:58 +03:00
^- form:m
2019-10-11 01:30:24 +03:00
;< ~ bind:m (send-wait until)
(take-wake `until)
2019-09-26 07:12:58 +03:00
::
++ sleep
|= for=@dr
=/ m (strand ,~)
2019-09-26 07:12:58 +03:00
^- form:m
;< now=@da bind:m get-time
(wait (add now for))
2019-09-26 08:43:14 +03:00
::
2019-10-11 01:30:24 +03:00
++ send-wait
|= until=@da
=/ m (strand ,~)
2019-10-11 01:30:24 +03:00
^- form:m
2019-11-19 07:36:21 +03:00
=/ =card:agent:gall
2019-10-11 01:30:24 +03:00
[%pass /wait/(scot %da until) %arvo %b %wait until]
(send-raw-card card)
::
2019-09-27 20:40:22 +03:00
++ set-timeout
|* computation-result=mold
=/ m (strand ,computation-result)
2019-09-27 20:40:22 +03:00
|= [time=@dr computation=form:m]
^- form:m
;< now=@da bind:m get-time
=/ when (add now time)
2019-11-19 07:36:21 +03:00
=/ =card:agent:gall
2019-09-27 20:40:22 +03:00
[%pass /timeout/(scot %da when) %arvo %b %wait when]
;< ~ bind:m (send-raw-card card)
|= tin=strand-input:strand
2019-09-27 20:40:22 +03:00
=* loop $
?: ?& ?=([~ %sign [%timeout @ ~] %b %wake *] in.tin)
=((scot %da when) i.t.wire.u.in.tin)
==
`[%fail %timeout ~]
=/ c-res (computation tin)
?: ?=(%cont -.next.c-res)
c-res(self.next ..loop(computation self.next.c-res))
?: ?=(%done -.next.c-res)
2019-11-19 07:36:21 +03:00
=/ =card:agent:gall
2019-09-27 20:40:22 +03:00
[%pass /timeout/(scot %da when) %arvo %b %rest when]
c-res(cards [card cards.c-res])
c-res
::
++ send-request
|= =request:http
=/ m (strand ,~)
2019-09-27 20:40:22 +03:00
^- form:m
(send-raw-card %pass /request %arvo %i %request request *outbound-config:iris)
::
2019-10-11 01:30:24 +03:00
++ send-cancel-request
=/ m (strand ,~)
2019-10-11 01:30:24 +03:00
^- form:m
(send-raw-card %pass /request %arvo %i %cancel-request ~)
::
2019-09-27 20:40:22 +03:00
++ take-client-response
=/ m (strand ,client-response:iris)
2019-09-27 20:40:22 +03:00
^- form:m
|= tin=strand-input:strand
2019-09-27 20:40:22 +03:00
?+ in.tin `[%skip ~]
~ `[%wait ~]
[~ %sign [%request ~] %i %http-response %finished *]
`[%done client-response.sign-arvo.u.in.tin]
==
::
2019-11-06 10:24:41 +03:00
:: Wait until we get an HTTP response or cancelation and unset contract
::
++ take-maybe-sigh
=/ m (strand ,(unit httr:eyre))
2019-11-06 10:24:41 +03:00
^- form:m
;< rep=(unit client-response:iris) bind:m
take-maybe-response
?~ rep
(pure:m ~)
:: XX s/b impossible
::
?. ?=(%finished -.u.rep)
(pure:m ~)
(pure:m (some (to-httr:iris +.u.rep)))
::
2019-10-11 01:30:24 +03:00
++ take-maybe-response
=/ m (strand ,(unit client-response:iris))
2019-10-11 01:30:24 +03:00
^- form:m
|= tin=strand-input:strand
2019-10-11 01:30:24 +03:00
?+ in.tin `[%skip ~]
~ `[%wait ~]
[~ %sign [%request ~] %i %http-response %cancel *]
`[%done ~]
[~ %sign [%request ~] %i %http-response %finished *]
`[%done `client-response.sign-arvo.u.in.tin]
==
::
2019-09-27 20:40:22 +03:00
++ extract-body
|= =client-response:iris
=/ m (strand ,cord)
2019-09-27 20:40:22 +03:00
^- form:m
?> ?=(%finished -.client-response)
?> ?=(^ full-file.client-response)
(pure:m q.data.u.full-file.client-response)
::
++ fetch-cord
2019-09-27 20:40:22 +03:00
|= url=tape
=/ m (strand ,cord)
2019-09-27 20:40:22 +03:00
^- form:m
=/ =request:http [%'GET' (crip url) ~ ~]
;< ~ bind:m (send-request request)
;< =client-response:iris bind:m take-client-response
(extract-body client-response)
::
++ fetch-json
|= url=tape
=/ m (strand ,json)
^- form:m
;< =cord bind:m (fetch-cord url)
2019-09-27 20:40:22 +03:00
=/ json=(unit json) (de-json:html cord)
?~ json
(strand-fail %json-parse-error ~)
2019-09-27 20:40:22 +03:00
(pure:m u.json)
::
2019-11-26 08:30:41 +03:00
++ hiss-request
|= =hiss:eyre
=/ m (strand ,(unit httr:eyre))
^- form:m
;< ~ bind:m (send-request (hiss-to-request:html hiss))
take-maybe-sigh
::
2020-04-18 05:50:03 +03:00
:: +build-fail: build the source file at the specified $beam
2020-03-21 01:30:24 +03:00
::
2020-04-18 05:50:03 +03:00
++ build-file
|= [[=ship =desk =case] =spur]
=* arg +<
=/ m (strand ,vase)
^- form:m
;< =riot:clay bind:m
(warp ship desk ~ %sing %a case (flop spur))
?~ riot
(strand-fail %build-file >arg< ~)
?> =(%vase p.r.u.riot)
(pure:m !<(vase q.r.u.riot))
2020-04-18 05:50:03 +03:00
:: +build-mark: build a mark definition to a $dais
::
++ build-mark
|= [[=ship =desk =case] mak=mark]
=* arg +<
=/ m (strand ,dais:clay)
^- form:m
;< =riot:clay bind:m
(warp ship desk ~ %sing %b case /[mak])
?~ riot
(strand-fail %build-mark >arg< ~)
?> =(%dais p.r.u.riot)
(pure:m !<(dais:clay q.r.u.riot))
:: +build-cast: build a mark conversion gate ($tube)
::
++ build-cast
|= [[=ship =desk =case] =mars:clay]
=* arg +<
=/ m (strand ,tube:clay)
^- form:m
;< =riot:clay bind:m
(warp ship desk ~ %sing %c case /[a.mars]/[b.mars])
?~ riot
(strand-fail %build-cast >arg< ~)
?> =(%tube p.r.u.riot)
(pure:m !<(tube:clay q.r.u.riot))
2020-03-21 01:30:24 +03:00
::
:: Read from Clay
::
++ warp
|= [=ship =riff:clay]
=/ m (strand ,riot:clay)
;< ~ bind:m (send-raw-card %pass /warp %arvo %c %warp ship riff)
(take-writ /warp)
::
2020-04-20 08:33:29 +03:00
++ read-file
|= [[=ship =desk =case:clay] =spur]
=* arg +<
=/ m (strand ,cage)
;< =riot:clay bind:m (warp ship desk ~ %sing %x case (flop spur))
?~ riot
(strand-fail %read-file >arg< ~)
(pure:m r.u.riot)
::
++ check-for-file
|= [[=ship =desk =case:clay] =spur]
=/ m (strand ,?)
;< =riot:clay bind:m (warp ship desk ~ %sing %x case (flop spur))
(pure:m ?=(^ riot))
::
2020-04-19 12:11:01 +03:00
++ list-tree
|= [[=ship =desk =case:clay] =spur]
=* arg +<
=/ m (strand ,(list path))
;< =riot:clay bind:m (warp ship desk ~ %sing %t case (flop spur))
?~ riot
(strand-fail %list-tree >arg< ~)
(pure:m !<((list path) q.r.u.riot))
::
:: Take Clay read result
::
++ take-writ
|= =wire
=/ m (strand ,riot:clay)
^- form:m
|= tin=strand-input:strand
?+ in.tin `[%skip ~]
~ `[%wait ~]
2020-05-08 06:58:03 +03:00
[~ %sign * ?(%b %c) %writ *]
?. =(wire wire.u.in.tin)
`[%skip ~]
`[%done +>.sign-arvo.u.in.tin]
==
::
2019-09-26 08:43:14 +03:00
:: Queue on skip, try next on fail %ignore
::
++ main-loop
|* a=mold
=/ m (strand ,~)
=/ m-a (strand ,a)
=| queue=(qeu (unit input:strand))
=| active=(unit [in=(unit input:strand) =form:m-a forms=(list $-(a form:m-a))])
2019-09-27 20:40:22 +03:00
=| state=a
2019-09-29 07:44:31 +03:00
|= forms=(lest $-(a form:m-a))
2019-09-26 08:43:14 +03:00
^- form:m
|= tin=strand-input:strand
2019-09-26 08:43:14 +03:00
=* top `form:m`..$
=. queue (~(put to queue) in.tin)
|^ (continue bowl.tin)
::
++ continue
|= =bowl:strand
2019-09-26 08:43:14 +03:00
^- output:m
?> =(~ active)
?: =(~ queue)
`[%cont top]
=^ in=(unit input:strand) queue ~(get to queue)
2019-09-26 08:43:14 +03:00
^- output:m
2019-10-11 01:30:24 +03:00
=. active `[in (i.forms state) t.forms]
2019-09-26 08:43:14 +03:00
^- output:m
(run bowl in)
::
++ run
^- form:m
|= tin=strand-input:strand
2019-09-26 08:43:14 +03:00
^- output:m
?> ?=(^ active)
=/ res (form.u.active tin)
=/ =output:m
?- -.next.res
%wait `[%wait ~]
%skip `[%cont ..$(queue (~(put to queue) in.tin))]
2019-10-11 01:30:24 +03:00
%cont `[%cont ..$(active `[in.u.active self.next.res forms.u.active])]
2019-09-27 20:40:22 +03:00
%done (continue(active ~, state value.next.res) bowl.tin)
2019-09-26 08:43:14 +03:00
%fail
2019-09-29 07:44:31 +03:00
?: &(?=(^ forms.u.active) ?=(%ignore p.err.next.res))
2019-10-11 01:30:24 +03:00
%= $
active `[in.u.active (i.forms.u.active state) t.forms.u.active]
in.tin in.u.active
==
2019-09-26 08:43:14 +03:00
`[%fail err.next.res]
==
[(weld cards.res cards.output) next.output]
--
2019-11-06 10:24:41 +03:00
::
2019-11-12 08:36:32 +03:00
++ retry
|* result=mold
|= [crash-after=(unit @ud) computation=_*form:(strand (unit result))]
=/ m (strand ,result)
2019-11-12 08:36:32 +03:00
=| try=@ud
2019-11-14 07:00:56 +03:00
|- ^- form:m
=* loop $
?: =(crash-after `try)
(strand-fail %retry-too-many ~)
2019-11-14 07:00:56 +03:00
;< ~ bind:m (backoff try ~m1)
;< res=(unit result) bind:m computation
?^ res
(pure:m u.res)
loop(try +(try))
::
++ backoff
|= [try=@ud limit=@dr]
=/ m (strand ,~)
2019-11-14 07:00:56 +03:00
^- form:m
;< eny=@uvJ bind:m get-entropy
%- sleep
%+ min limit
?: =(0 try) ~s0
%+ add
(mul ~s1 (bex (dec try)))
(mul ~s0..0001 (~(rad og eny) 1.000))
2019-11-06 10:24:41 +03:00
::
:: ----
::
:: Output
::
++ flog
|= =flog:dill
=/ m (strand ,~)
2019-11-06 10:24:41 +03:00
^- form:m
(send-raw-card %pass / %arvo %d %flog flog)
::
++ flog-text
|= =tape
=/ m (strand ,~)
2019-11-06 10:24:41 +03:00
^- form:m
(flog %text tape)
::
++ flog-tang
|= =tang
=/ m (strand ,~)
2019-11-06 10:24:41 +03:00
^- form:m
=/ =wall
(zing (turn (flop tang) (cury wash [0 80])))
|- ^- form:m
=* loop $
?~ wall
(pure:m ~)
;< ~ bind:m (flog-text i.wall)
loop(wall t.wall)
::
2020-05-15 10:58:36 +03:00
++ trace
|= =tang
=/ m (strand ,~)
^- form:m
(pure:m ((slog tang) ~))
::
2019-11-26 08:30:41 +03:00
++ app-message
|= [app=term =cord =tang]
=/ m (strand ,~)
^- form:m
=/ msg=tape :(weld (trip app) ": " (trip cord))
;< ~ bind:m (flog-text msg)
(flog-tang tang)
::
2019-11-06 10:24:41 +03:00
:: ----
::
:: Handle domains
::
++ install-domain
|= =turf
=/ m (strand ,~)
2019-11-06 10:24:41 +03:00
^- form:m
(send-raw-card %pass / %arvo %e %rule %turf %put turf)
2019-11-15 00:31:44 +03:00
::
:: ----
::
2019-11-26 08:30:41 +03:00
:: Threads
2019-11-15 00:31:44 +03:00
::
++ start-thread
2019-11-15 00:31:44 +03:00
|= file=term
=/ m (strand ,tid:spider)
2019-11-15 00:31:44 +03:00
^- form:m
;< =bowl:spider bind:m get-bowl
=/ tid (scot %ta (cat 3 'strand_' (scot %uv (sham file eny.bowl))))
=/ poke-vase !>([`tid.bowl `tid file *vase])
2019-11-15 00:31:44 +03:00
;< ~ bind:m (poke-our %spider %spider-start poke-vase)
;< ~ bind:m (sleep ~s0) :: wait for thread to start
(pure:m tid)
2019-11-22 23:46:30 +03:00
::
+$ thread-result
(each vase [term (list tang)])
::
++ await-thread
|= [file=term args=vase]
=/ m (strand ,thread-result)
^- form:m
;< =bowl:spider bind:m get-bowl
=/ tid (scot %ta (cat 3 'strand_' (scot %uv (sham file eny.bowl))))
=/ tid (scot %ta (cat 3 'strand_' (scot %uv (sham file eny.bowl))))
=/ poke-vase !>([`tid.bowl `tid file args])
;< ~ bind:m (watch-our /awaiting/[tid] %spider /thread-result/[tid])
;< ~ bind:m (poke-our %spider %spider-start poke-vase)
;< ~ bind:m (sleep ~s0) :: wait for thread to start
;< =cage bind:m (take-fact /awaiting/[tid])
?+ p.cage ~|([%strange-thread-result p.cage file tid] !!)
%thread-done (pure:m %& q.cage)
%thread-fail (pure:m %| !<([term (list tang)] q.cage))
==
2019-09-26 07:12:58 +03:00
--