Merge pull request #1610 from urbit/philip/tapp-scry

add +scry to lib/stdio
This commit is contained in:
Jared Tobin 2019-08-12 15:03:10 -07:00 committed by GitHub
commit 37edcc8525
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 4 deletions

View File

@ -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

View File

@ -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
::

View File

@ -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)]