urbit/pkg/landscape/app/graph-pull-hook.hoon

72 lines
1.5 KiB
Plaintext
Raw Normal View History

2020-08-19 22:22:20 +03:00
/- *resource
/+ store=graph-store, graph, default-agent, verb, dbug, pull-hook
~% %graph-pull-hook-top ..part ~
2020-08-19 22:22:20 +03:00
|%
+$ card card:agent:gall
++ config
^- config:pull-hook
:* %graph-store
update:store
%graph-update
%graph-push-hook
2021-09-28 02:43:36 +03:00
3 3
%.n
2020-08-19 22:22:20 +03:00
==
+$ state-nul ~
+$ state-0 [%0 ~]
+$ versioned-state
$% state-0
==
2020-08-19 22:22:20 +03:00
--
::
%- agent:dbug
%+ verb |
2020-08-19 22:22:20 +03:00
^- agent:gall
%- (agent:pull-hook config)
^- (pull-hook:pull-hook config)
=| state-0
=* state -
2020-08-19 22:22:20 +03:00
|_ =bowl:gall
+* this .
def ~(. (default-agent this %|) bowl)
dep ~(. (default:pull-hook this config) bowl)
gra ~(. graph bowl)
io ~(. agentio bowl)
pass pass:io
2020-08-19 22:22:20 +03:00
::
++ on-init on-init:def
++ on-save !>(state)
++ on-load
|= =vase
?: =(q.vase ~)
:_ this
(poke-self:pass kick+!>(%kick))^~
`this
::
++ on-poke on-poke:def
++ on-peek on-peek:def
++ on-arvo on-arvo:def
++ on-fail on-fail:def
++ on-agent on-agent:def
++ on-watch on-watch:def
++ on-leave on-leave:def
2020-08-19 22:22:20 +03:00
++ on-pull-nack
|= [=resource =tang]
^- (quip card _this)
%- (slog leaf+"nacked {<resource>}" tang)
2020-08-19 22:22:20 +03:00
:_ this
?. (~(has in get-keys:gra) resource) ~
2021-09-28 02:43:36 +03:00
=- [%pass /pull-nack %agent [our.bowl %graph-store] %poke %graph-update-3 -]~
2020-08-19 22:26:58 +03:00
!> ^- update:store
[now.bowl [%archive-graph resource]]
2020-08-19 22:22:20 +03:00
::
++ on-pull-kick
|= =resource
^- (unit path)
=/ maybe-time (peek-update-log:gra resource)
2020-08-19 22:22:20 +03:00
?~ maybe-time `/
`/(scot %da u.maybe-time)
::
++ resource-for-update resource-for-update:gra
2020-08-19 22:22:20 +03:00
--