on master help sign in
gall-guide: change code and add explanations about bowl & multiple cards
commitfe738e3610e15ba6c38208cecdf70a938e731e87 authorTinnus Napbus <admin@tinnus-napbus.xyz> dateWed 8 Dec 2021, 04:11 (5 years ago) parent3d29f60
2 files changed+25−1
content/docs/userspace/gall-guide/2-agent.md+7 content/docs/userspace/gall-guide/8-subscriptions.md+18−1
content/docs/userspace/gall-guide/2-agent.md+7
@@ -62,6 +62,13 @@ arms of the agent have access to that data. For the exact structure and contents
6262of the bowl, have a read through [its entry in the Gall vane types
6363documentation](/docs/arvo/gall/data-types#bowl).
6464
65+One important thing to note is that the bowl is only repopulated when there's a
66+new Arvo event. If a local agent or web client were to send multiple
67+messages to your agent at the same time, these would all arrive in the same
68+event. This means if your agent depended on a unique date-time or entropy to
69+process each message, you could run into problems if your agent doesn't account
70+for this possibility.
71+
6572## State
6673
6774If you've worked through [Hoon School](/docs/hoon/hoon-school/intro), you may
content/docs/userspace/gall-guide/8-subscriptions.md+18−1
@@ -466,6 +466,8 @@ This is a very simple mark file for the `update` type.
466466 ^- (quip card _state)
467467 ?- -.action
468468 %add
469+ ?: (~(has by tasks) now.bowl)
470+ $(now.bowl (add now.bowl ~s0..0001))
469471 :_ state(tasks (~(put by tasks) now.bowl [name.action %.n]))
470472 :~ :* %give %fact ~[/updates] %todo-update
471473 !>(`update:todo`[%add now.bowl name.action])
@@ -542,7 +544,22 @@ in `on-poke` with:
542544?> =(src.bowl our.bowl)
543545```
544546
545−Let's look at `on-watch`:
547+Additionally, you might notice the `%add` case in `handle-poke` begins with the
548+following:
549+
550+```hoon
551+?: (~(has by tasks) now.bowl)
552+ $(now.bowl (add now.bowl ~s0..0001))
553+```
554+
555+Back in lesson two, we mentioned that the bowl is only repopulated when there's
556+a new Arvo event, so simultaneous messages from a local agent or web client
557+would be processed with the same bowl. Since we're using `now.bowl` for the task
558+ID, this means multiple `%add` actions could collide. To handle this case, we
559+check if there's already an entry in the `tasks` map with the current date-time,
560+and if there is, we increase the time by a fraction of a second and try again.
561+
562+Let's now look at `on-watch`:
546563
547564```hoon
548565++ on-watch