shrub/pkg/arvo/lib/strandio.hoon

678 lines
16 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
::
++ 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-json
|= url=tape
=/ m (strand ,json)
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
;< =cord bind:m (extract-body client-response)
=/ 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-03-21 01:30:24 +03:00
:: Run ford build
::
++ ford-build
|= =schematic:ford
=/ m (strand ,build-result:ford)
^- form:m
;< ~ bind:m (send-raw-card %pass /ford-build %arvo %f %build | schematic)
;< =made-result:ford bind:m (take-made-result /ford-build)
?: ?=(%incomplete -.made-result)
(strand-fail %ford-incomplete tang.made-result)
(pure:m build-result.made-result)
::
:: Take ford build result
::
++ take-made-result
|= =wire
=/ m (strand ,made-result:ford)
^- form:m
|= tin=strand-input:strand
?+ in.tin `[%skip ~]
~ `[%wait ~]
[~ %sign * %f %made *]
?. =(wire wire.u.in.tin)
`[%skip ~]
`[%done result.sign-arvo.u.in.tin]
==
::
:: Run several taggged ford builds
::
++ build-map
|= builds=(map path schematic:ford)
=/ m (strand ,(map path build-result:ford))
2020-03-21 01:30:24 +03:00
^- form:m
=/ schematics=(list schematic:ford)
%+ turn ~(tap by builds)
|= [=path =schematic:ford]
[[%$ %noun !>(path)] schematic]
2020-03-21 01:30:24 +03:00
::
;< =build-result:ford bind:m (ford-build %list schematics)
?: ?=(%error -.build-result)
(strand-fail %ford-error message.build-result)
?> ?=(%list -.+.build-result)
::
=| produce=(map path build-result:ford)
2020-03-21 01:30:24 +03:00
|- ^- form:m
=* loop $
?^ results.build-result
?> ?=([[%success %$ %noun *] *] +.i.results.build-result)
=. produce
%+ ~(put by produce)
!<(path q.cage.head.i.results.build-result)
2020-03-21 01:30:24 +03:00
tail.i.results.build-result
loop(results.build-result t.results.build-result)
(pure:m produce)
::
:: Run several taggged ford builds
::
++ build-cages
|= builds=(map path schematic:ford)
=/ m (strand ,(map path cage))
^- form:m
;< result-map=(map path build-result:ford) bind:m (build-map builds)
=/ results=(list [=path =build-result:ford]) ~(tap by result-map)
=| produce=(map path cage)
|- ^- form:m
=* loop $
?^ results
?: ?=(%error -.build-result.i.results)
(strand-fail %ford-error message.build-result.i.results)
=. produce
%+ ~(put by produce) path.i.results
(result-to-cage:ford build-result.i.results)
loop(results t.results)
(pure:m produce)
::
2020-03-21 01:30:24 +03:00
:: Run ford %core build
::
++ build-core
|= =rail:ford
=/ m (strand ,vase)
^- form:m
;< =build-result:ford bind:m (ford-build %core rail)
?: ?=(%error -.build-result)
(strand-fail %ford-error message.build-result)
?> ?=(%core -.+.build-result)
(pure:m vase.build-result)
::
:: Run ford %core builds
::
++ build-cores
|= rails=(map path rail:ford)
=/ m (strand ,(map path vase))
2020-03-21 01:30:24 +03:00
^- form:m
=/ builds
%- ~(run by rails)
|= =rail:ford
[%core rail]
::
;< result-map=(map path build-result:ford) bind:m (build-map builds)
=/ results=(list [=path =build-result:ford]) ~(tap by result-map)
=| produce=(map path vase)
2020-03-21 01:30:24 +03:00
|- ^- form:m
=* loop $
?^ results
?: ?=(%error -.build-result.i.results)
(strand-fail %ford-error message.build-result.i.results)
?> ?=(%core -.+.build-result.i.results)
=. produce
(~(put by produce) path.i.results vase.build-result.i.results)
2020-03-21 01:30:24 +03:00
loop(results t.results)
(pure:m produce)
::
:: 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)
::
:: Take Clay read result
::
++ take-writ
|= =wire
=/ m (strand ,riot:clay)
^- form:m
|= tin=strand-input:strand
?+ in.tin `[%skip ~]
~ `[%wait ~]
[~ %sign * %b %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)
::
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
--