Simplified %sink (#8)

* Simplified %sink

* Formatting
This commit is contained in:
iko 2023-07-09 12:17:46 +03:00 committed by GitHub
parent 8168841cfa
commit 5391624c2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 32 deletions

View File

@ -21,12 +21,11 @@
%- agent:dbug
=/ state *state-0
=/ snik
%+ sink ~[/sync]
|=(stat=versioned-state (tap:j-orm journal.stat))
=/ sink (snik state)
=* entries (tap:j-orm journal.stat)
=/ snik (sink ~[/sync])
=/ sink (snik entries)
^- agent:gall
::
|_ =bowl:gall
+* this .
def ~(. (default-agent this %|) bowl)
@ -40,7 +39,7 @@
|= old-vase=vase
^- (quip card _this)
=/ state !<(versioned-state old-vase)
`this(state state, sink (snik state))
`this(state state, sink (snik entries))
::
++ on-poke
|= [=mark =vase]
@ -51,7 +50,7 @@
=/ now=@ (unique-time now.bowl log.state)
=/ act !<(action vase)
=. state (poke-action act)
=^ card sink (sync:sink state)
=^ card sink (sync:sink entries)
:_ this(log.state (put:log-orm log.state now act))
~[(fact:io journal-update+!>(`update`[now act]) ~[/updates]) card]
::
@ -93,7 +92,7 @@
[%all ~]
:^ ~ ~ %journal-update
!> ^- update
[now %jrnl (tap:j-orm journal.state)]
[now %jrnl entries]
::
[%before @ @ ~]
=/ before=@ (rash i.t.t.t.path dem)

View File

@ -1,27 +1,26 @@
/+ noun-diff
|%
++ clog
|$ [stut]
$%
[%flush stut]
[%drain patch:noun-diff]
==
++ sink
|* [pats=(list path) extract=$-(* *)]
|* stat=*
|@
++ sync
|= [stat=_stat]
^- [card:agent:gall _..sync]
=/ dif
%+ diff:noun-diff (extract ^stat) (extract stat)
:-
~& [%give %fact pats %noun !>(^-((clog) [%drain dif]))]
[%give %fact pats %noun !>(^-((clog) [%drain dif]))]
..sync(stat stat)
++ paths pats
++ flush
^- card:agent:gall
[%give %fact pats %noun !>(^-((clog) [%flush (extract stat)]))]
--
++ clog
|$ [stut]
$%
[%flush stut]
[%drain patch:noun-diff]
==
++ sink
|* pats=(list path)
|* stat=*
|@
++ sync
|= [stat=_stat]
^- [card:agent:gall _..sync]
=/ dif
%+ diff:noun-diff ^stat stat
:-
[%give %fact pats %noun !>(^-((clog) [%drain dif]))]
..sync(stat stat)
++ paths pats
++ flush
^- card:agent:gall
[%give %fact pats %noun !>(^-((clog) [%flush (extract stat)]))]
--
--