Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add take-fact-or-kick #1763

Merged
merged 1 commit into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions desks/realm/lib/db.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -1174,9 +1174,10 @@
++ en-vent
|= =vent
^- json
%+ frond
%row-id
(row-id-to-json id.vent)
?- -.vent
%ack s/%ack
%row-id (frond row-id+(row-id-to-json id.vent))
==
::
++ en-db-changes
|= chs=db-changes
Expand Down
1 change: 1 addition & 0 deletions desks/realm/sur/db.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,6 @@
::
+$ vent
$% [%row-id =id:common]
[%ack ~]
==
--
29 changes: 26 additions & 3 deletions desks/realm/ted/venter.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
:: it will give back the id of the `%create`ed object
/- spider, db
/+ *strandio
|^
=, strand=strand:spider
^- thread:spider
|= arg=vase
=/ m (strand ,vase)
^- form:m
=/ axn=(unit action:db) !<((unit action:db) arg)
?~ axn (strand-fail %no-arg ~)
?. ?=(%create -.u.axn) (strand-fail %no-arg ~)
?. ?=(%create -.u.axn) (strand-fail %bad-action ~)
;< our=@p bind:m get-our
;< now=@da bind:m get-time
=/ data-path=path path.input-row.u.axn
Expand All @@ -25,5 +26,27 @@
;< host=ship bind:m (scry ship scry-path)
;< ~ bind:m (watch wire [host %db] wire)
;< ~ bind:m (poke [host %db] db-action+!>([%create [our now] +>.u.axn]))
;< =cage bind:m (take-fact wire)
(pure:m q.cage)
;< cage=(unit cage) bind:m (take-fact-or-kick wire)
?^ cage
(pure:m q.u.cage)
(pure:m !>([%ack ~]))
::
Copy link
Contributor Author

@niblyx-malnus niblyx-malnus Jun 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just a trivial combination of +take-fact and +take-kick from strandio (referencing +take-fact-or-kick below)

++ take-fact-or-kick
|= =wire
=/ m (strand ,(unit cage))
^- form:m
|= tin=strand-input:strand
?+ in.tin `[%skip ~]
~ `[%wait ~]
::
[~ %agent * %fact *]
?. =(watch+wire wire.u.in.tin)
`[%skip ~]
`[%done (some cage.sign.u.in.tin)]
::
[~ %agent * %kick *]
?. =(watch+wire wire.u.in.tin)
`[%skip ~]
`[%done ~]
==
--