mirror of
https://github.com/urbit/shrub.git
synced 2024-12-02 08:55:07 +03:00
Merge pull request #1610 from urbit/philip/tapp-scry
add +scry to lib/stdio
This commit is contained in:
commit
37edcc8525
@ -62,6 +62,25 @@
|
||||
::
|
||||
:: ----
|
||||
::
|
||||
:: Scry from the namespace.
|
||||
::
|
||||
:: Direct scrys are impossible in a tapp, so this routes around that.
|
||||
::
|
||||
++ scry
|
||||
|* result-type=mold
|
||||
|= =path
|
||||
=/ m (async ,result-type)
|
||||
;< ~ bind:m (send-raw-card %scry path)
|
||||
|= =async-input
|
||||
:^ ~ ~ ~
|
||||
?~ in.async-input
|
||||
[%wait ~]
|
||||
?. ?=(%scry-result -.sign.u.in.async-input)
|
||||
[%fail %expected-scry-result >got=-.sign< ~]
|
||||
[%done (result-type result.sign.u.in.async-input)]
|
||||
::
|
||||
:: ----
|
||||
::
|
||||
:: Outgoing HTTP requests
|
||||
::
|
||||
++ send-request
|
||||
|
@ -428,6 +428,9 @@
|
||||
|= =async-input:async-lib
|
||||
^- (quip move _this-tapp)
|
||||
=/ m tapp-async
|
||||
=| moves=(list move)
|
||||
=| scrys=(list path)
|
||||
|- ^- (quip move _this-tapp)
|
||||
?~ active
|
||||
~| %no-active-async
|
||||
~| ?~ in.async-input
|
||||
@ -442,14 +445,27 @@
|
||||
%& p.out
|
||||
%| [[~ [%fail contracts.u.active %crash p.out]] u.active]
|
||||
==
|
||||
=. moves (weld moves (skip moves.r |=(=move =(%scry -.q.move))))
|
||||
=. scrys
|
||||
%+ weld scrys
|
||||
^- (list path)
|
||||
%+ murn moves.r
|
||||
|= =move
|
||||
^- (unit path)
|
||||
?. ?=(%scry -.q.move)
|
||||
~
|
||||
`path.q.move
|
||||
?^ scrys
|
||||
=/ scry-result .^(* i.scrys)
|
||||
$(scrys t.scrys, in.async-input `[i.scrys %scry-result scry-result])
|
||||
=> .(active `(unit eval-form:eval:tapp-async)`active) :: TMI
|
||||
=^ moves=(list move) this-tapp
|
||||
=^ final-moves=(list move) this-tapp
|
||||
?- -.eval-result.r
|
||||
%next `this-tapp
|
||||
%fail (fail-async [contracts err]:eval-result.r)
|
||||
%done (done-async [contracts value]:eval-result.r)
|
||||
==
|
||||
[(weld moves.r moves) this-tapp]
|
||||
[(weld moves final-moves) this-tapp]
|
||||
::
|
||||
:: Fails currently-running async
|
||||
::
|
||||
|
@ -4,7 +4,8 @@
|
||||
:: Possible async calls
|
||||
::
|
||||
+$ card
|
||||
$% [%wait wire @da]
|
||||
$% [%scry =path]
|
||||
[%wait wire @da]
|
||||
[%rest wire @da]
|
||||
[%poke wire dock poke-data]
|
||||
[%peer wire dock path]
|
||||
@ -24,7 +25,8 @@
|
||||
:: Possible async responses
|
||||
::
|
||||
+$ sign
|
||||
$% [%wake error=(unit tang)]
|
||||
$% [%scry-result result=*]
|
||||
[%wake error=(unit tang)]
|
||||
[%coup =dock error=(unit tang)]
|
||||
[%quit =dock =path]
|
||||
[%reap =dock =path error=(unit tang)]
|
||||
|
Loading…
Reference in New Issue
Block a user