mirror of
https://github.com/sigilante/global-store.git
synced 2024-11-23 08:40:08 +03:00
Post 1.0.0
This commit is contained in:
parent
b13fdf2544
commit
4169429c39
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 Sigilante
|
||||
Copyright (c) 2023 Urbit Foundation
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
88
README.md
88
README.md
@ -1,79 +1,77 @@
|
||||
# `%global-store`
|
||||
# `%gs` Global Store
|
||||
|
||||
_a simple key-value storage solution for ship-global values_
|
||||
|
||||
_"making people behave like they care about integration by giving them easier inroads" (~rabsef-bicrym)_
|
||||
|
||||
`%global-store` intends to solve the problem of ship-wide configuration and
|
||||
`%gs` intends to solve the problem of ship-wide configuration and
|
||||
settings without any json compatibility overhead
|
||||
|
||||
it's simply a map for desks and keys to vases of values.
|
||||
|
||||
some things you could use it for:
|
||||
|
||||
- [`l10n`](https://github.com/sigilante/l10n) localization settings like
|
||||
preferred language or script or currency
|
||||
- secret keys (pending urbit security)
|
||||
- localization settings
|
||||
- visual preferences (dark mode)
|
||||
- secret keys (pending hardened urbit security)
|
||||
- profile features beyond `%groups`
|
||||
|
||||
just set and scry
|
||||
just set and scry (or subscribe)
|
||||
|
||||
###### pokes
|
||||
|
||||
- `[%let =desk]` creates a desk key-value store (kvs)
|
||||
- `[%lie =desk]` removes a desk kvs
|
||||
- `[%put =desk =key =value]` puts a key in a desk's kvs (key is a vase)
|
||||
- `[%del =desk =key]` removes a key
|
||||
- `[%mode =arena =perm]` sets perms (see below)
|
||||
- `[%whitelist =ship =perm]` add a ship to whitelist for perms (see below)
|
||||
- `[%blacklist =ship]` removes a ship from whitelist (so not really a true blacklist)
|
||||
- `[%lockdown ~]` removes all perms except yours
|
||||
- `%put` - put a value with a key onto a desk's kvs
|
||||
- `%del` - delete a key in a desk's kvs (rm)
|
||||
- `%lop` - delete keys in a desk's kvs (rm -r)
|
||||
::
|
||||
- `%enroll` - put an arena on the roll
|
||||
- `%unroll` - remove an arena from the roll
|
||||
- `%lockdown` - set only self to read-write perms for a desk
|
||||
|
||||
###### peeks
|
||||
|
||||
you can peek for a value at `/[desk]/[key]` which returns a `(unit vase)`
|
||||
|
||||
you can peek for all of a desk's values at `/[desk]` which returns a
|
||||
`(unit (map @tas vase))`
|
||||
- `/x/desk/[desk]`
|
||||
- `/x/desk/key/[desk]/[key]`
|
||||
- `/x/u/desk/[desk]` existence check
|
||||
- `/x/u/desk/key/[desk]/[key]` existence check
|
||||
|
||||
###### subscriptions
|
||||
|
||||
you can subscribe to a value at `/[desk]/[key]` for a gift every time it changes
|
||||
|
||||
you can subscribe to all of a desk's values at `/[desk]` for a gift every time
|
||||
any value changes
|
||||
- `/desk/[desk]`
|
||||
- `/desk/key/[desk]/[key]`
|
||||
- `/u/desk/[desk]`
|
||||
- `/u/desk/key/[desk]/[key]`
|
||||
|
||||
###### perms
|
||||
|
||||
there's not currently a per-agent permissions model altho i'm not averse to that
|
||||
|
||||
right now you can set perms by:
|
||||
|
||||
1. `our` - always `%w` so you can write (`%w` implies `%r`)
|
||||
2. `%moon` - by default your team can `%w` write
|
||||
3. `roll` - you can add ships to a whitelist to `%r` read or `%w` write
|
||||
4. `%public` - or you can let everyone `%r` read
|
||||
- `%moon` - moons if you're a planet
|
||||
- `%orbit` - moons under same parent (if you're a moon)
|
||||
- `%kids` - sponsees (azimuth sense)
|
||||
- `%public` - free for all
|
||||
- `%ship` - whitelist
|
||||
|
||||
set types:
|
||||
|
||||
- `%r` - read
|
||||
- `%w` - write
|
||||
|
||||
###### some useful snippets
|
||||
|
||||
```hoon
|
||||
=global -build-file /=global-store=/sur/global-store/hoon
|
||||
:global-store &global-store-action [%let %example]
|
||||
:global-store &global-store-action [%put %example %message !>('hello world')]
|
||||
:global-store &global-store-action [%put %example %locale !>('en-US-Dsrt')]
|
||||
:global-store +dbug
|
||||
.^((unit (map @tas vase)) %gx /=global-store=/example/noun)
|
||||
.^((unit vase) %gx /=global-store=/example/message/noun)
|
||||
:global-store &global-store-action [%lie %example]
|
||||
:global-store +dbug
|
||||
=gs -build-file /=gs=/sur/gs/hoon
|
||||
::
|
||||
:gs|put :: :gs|put %desk /key/to noun+!>(42)
|
||||
:gs|del :: :gs|del %desk /key/to
|
||||
:gs|lop :: :gs|lop %desk /key/to
|
||||
::
|
||||
:gs|enroll :: :gs|enroll %desk /key/to arena perm
|
||||
:gs|unroll :: :gs|unroll %desk /key/to arena :gs|lockdown :: :gs|lockdown %desk
|
||||
::
|
||||
:gs +dbug
|
||||
```
|
||||
|
||||
###### status (wip ~2023.3.4)
|
||||
###### changelog
|
||||
|
||||
- [x] main code (pokes, peeks) works
|
||||
- [ ] test subs
|
||||
- [ ] decide about return marks/units
|
||||
- [ ] write generators to use pokes
|
||||
- [ ] use whitelist for real tho
|
||||
|
||||
- [ ] version `%one` should rework perms to be per-desk instead of global
|
||||
- `[1 0 0]` first public release, pokes/peeks/subs
|
||||
|
@ -1,7 +1,9 @@
|
||||
:: /sur/global-store.hoon
|
||||
:: /app/gs.hoon
|
||||
:::: ~lagrev-nocfep & ~midden-fabler
|
||||
:: Version ~2023.11.9
|
||||
::
|
||||
:: GLOBAL STORE
|
||||
::
|
||||
:: a simple key-value storage solution for ship-global values
|
||||
:: with a straightforward permissions model
|
||||
::
|
||||
@ -27,12 +29,18 @@
|
||||
:: receiving a gift in return
|
||||
::
|
||||
:: for a value you'll peek to
|
||||
:: /x/desk/[desk] or /x/desk/key/[desk]/[key]
|
||||
:: or subscribe to /desk/[desk] or /desk/key/[desk]/[key]
|
||||
:: /x/desk/[desk]
|
||||
:: /x/desk/key/[desk]/[key]
|
||||
:: /x/u/desk/[desk]
|
||||
:: /x/u/desk/key/[desk]/[key]
|
||||
::
|
||||
:: or subscribe to
|
||||
:: /desk/[desk]
|
||||
:: /desk/key/[desk]/[key]
|
||||
::
|
||||
:: the advantage of subscribing is that you receive changes to the value
|
||||
::
|
||||
/- *global-store,
|
||||
/- *gs,
|
||||
update
|
||||
/+ dbug,
|
||||
default-agent,
|
||||
@ -62,7 +70,7 @@
|
||||
|= [=mark =vase]
|
||||
^- (quip card _this)
|
||||
?+ mark (on-poke:def mark vase)
|
||||
%global-store-action
|
||||
%gs-action
|
||||
=+ !<(act=action vase)
|
||||
?- -.act
|
||||
%put
|
||||
@ -81,9 +89,10 @@
|
||||
(~(del by objs) u.old-hash)
|
||||
=/ =path [desk.act key.act]
|
||||
:_ this
|
||||
:~ [%give %fact ~[/desk/[desk.act]] %update !>(desk+(export-values desk.act))]
|
||||
[%give %fact ~[/u/desk/key/[desk.act]/[key.act]] %update !>(key+[desk.act key.act &])]
|
||||
[%give %fact ~[/desk/key/[desk.act]/[key.act]] %update !>(value+value.act)]
|
||||
:~ [%give %fact ~[[%desk desk.act ~]] %update !>(desk+(export-values desk.act))]
|
||||
[%give %fact ~[[%u %desk desk.act ~]] %update !>(has-desk+[desk.act &])]
|
||||
[%give %fact ~[[%u %desk %key desk.act key.act]] %update !>(has-key+[desk.act key.act &])]
|
||||
[%give %fact ~[[%desk %key desk.act key.act]] %update !>(value+value.act)]
|
||||
==
|
||||
::
|
||||
%del
|
||||
@ -95,9 +104,9 @@
|
||||
=? objs &(?=(^ hash) =(~ (~(get ju refs) u.hash)))
|
||||
(~(del by objs) u.hash)
|
||||
:_ this
|
||||
:~ [%give %fact ~[/desk/[desk.act]] %update !>(desk+(export-values desk.act))]
|
||||
[%give %fact ~[/u/desk/key/[desk.act]/[key.act]] %update !>(key+[desk.act key.act |])]
|
||||
[%give %fact ~[/desk/key/[desk.act]/[key.act]] %update !>(value+~)]
|
||||
:~ [%give %fact ~[[%desk desk.act ~]] %update !>(desk+(export-values desk.act))]
|
||||
[%give %fact ~[[%u %desk %key desk.act key.act]] %update !>(has-key+[desk.act key.act |])]
|
||||
[%give %fact ~[[%desk %key desk.act key.act]] %update !>(value+~)]
|
||||
==
|
||||
::
|
||||
%lop
|
||||
@ -121,11 +130,13 @@
|
||||
:: XX update all paths
|
||||
:_ this
|
||||
:: return desk empty, all keys empty, all key /u false, kicks
|
||||
:~ [%give %fact ~[/desk/[desk.act]] %update !>(desk+(export-values desk.act))]
|
||||
[%give %fact ~[/u/desk/key/[desk.act]/[key.act]] %update !>(key+[desk.act key.act |])]
|
||||
[%give %fact ~[/desk/key/[desk.act]/[key.act]] %update !>(value+value.act)]
|
||||
(give-updates desk.act)
|
||||
(give-kicks desk.act)
|
||||
;: welp
|
||||
(cull-keys [desk.act key.act])
|
||||
(give-updates desk.act)
|
||||
(give-kicks desk.act)
|
||||
:~ [%give %fact ~[[%desk desk.act ~]] %update !>(desk+(export-values desk.act))]
|
||||
[%give %fact ~[[%u %desk desk.act ~]] %update !>(has-desk+[desk.act (~(has of store) /[desk.act])])]
|
||||
==
|
||||
==
|
||||
::
|
||||
%enroll
|
||||
@ -216,6 +227,13 @@
|
||||
:_ this
|
||||
:~ [%give %fact ~ %update !>(value+response)]
|
||||
==
|
||||
:: /u/desk
|
||||
::
|
||||
[%u %desk desk=@ ~]
|
||||
=/ response (~(has of store) /[desk.pole])
|
||||
:_ this
|
||||
:~ [%give %fact ~ %update !>(has-desk+response)]
|
||||
==
|
||||
:: /u/desk/key
|
||||
::
|
||||
[%u %desk %key desk=@ key=*]
|
||||
@ -223,7 +241,7 @@
|
||||
[~ this]
|
||||
=/ response (~(has of store) desk.pole key.pole)
|
||||
:_ this
|
||||
:~ [%give %fact ~ %update !>(key+[desk.pole key.pole response])]
|
||||
:~ [%give %fact ~ %update !>(has-key+[desk.pole key.pole response])]
|
||||
==
|
||||
==
|
||||
++ on-agent on-agent:def
|
||||
@ -302,9 +320,24 @@
|
||||
^- (unit card)
|
||||
?. &(?=([desk=@ *] pole) =(desk desk.pole))
|
||||
~
|
||||
?: (can-read desk ship)
|
||||
?: (can-read ship pole)
|
||||
~
|
||||
`[%give %kick [pole ~] `ship]
|
||||
++ cull-keys
|
||||
|= [=desk =key]
|
||||
^- (list card)
|
||||
%- zing
|
||||
%+ murn ~(val by sup.bowl)
|
||||
|= [=ship =(pole knot)]
|
||||
^- (unit (list card))
|
||||
?. &(?=([desk=@ *] pole) =(desk desk.pole))
|
||||
~
|
||||
?: (can-read ship pole)
|
||||
~
|
||||
:- ~
|
||||
:~ [%give %fact ~[`path`[%u %desk %key desk key]] %update !>(has-key+[desk key |])]
|
||||
[%give %fact ~[`path`[%desk %key desk key]] %update !>(value+~)]
|
||||
==
|
||||
::
|
||||
++ give-updates
|
||||
|= arg=$@(=desk [=desk =key])
|
||||
@ -330,23 +363,27 @@
|
||||
%- sy
|
||||
%+ murn ~(val by sup.bowl)
|
||||
|= [* =(pole knot)]
|
||||
?. &(?=([desk=@ key=@ ~] pole) =(desk.pole desk))
|
||||
?. &(?=([desk=@ key=*] pole) =(desk.pole desk))
|
||||
~
|
||||
`key.pole
|
||||
::
|
||||
++ desk-update
|
||||
|= =desk
|
||||
^- card
|
||||
:* %give %fact [[desk ~] ~]
|
||||
:* %give %fact ~[/desk/[desk]]
|
||||
%update
|
||||
!>(desk+(~(get of store) desk))
|
||||
!>(desk+(export-values desk))
|
||||
==
|
||||
::
|
||||
++ value-update
|
||||
|= [=desk =key]
|
||||
^- card
|
||||
:* %give %fact [[desk key ~] ~]
|
||||
:* %give %fact ~[:(welp /desk/key /[desk] key)]
|
||||
%update
|
||||
!>(value+(~(get of store) [desk key]))
|
||||
!>(`^update`[value+(key-to-val desk key)])
|
||||
==
|
||||
--
|
||||
--
|
||||
|
||||
:: -need.?(%~ [i=/ t=it(/)])
|
||||
:: -have.[[@tas @tas @tas / %~] %~]
|
@ -1,2 +1,2 @@
|
||||
:~ %global-store
|
||||
:~ %gs
|
||||
==
|
||||
|
@ -1,9 +0,0 @@
|
||||
:~ title+'mine'
|
||||
info+'fixme'
|
||||
color+0xff.4400
|
||||
image+'https://freedom-club.sfo2.digitaloceanspaces.com/props/quartus/long-logo/ab_Quartus-05_only.png'
|
||||
version+[0 0 1]
|
||||
website+'https://dalten.org/'
|
||||
license+'REKT'
|
||||
site+/apps/mine
|
||||
==
|
@ -1,9 +0,0 @@
|
||||
:: :global-store|del %desk /key
|
||||
::
|
||||
/- *global-store
|
||||
:- %say
|
||||
|= $: ^
|
||||
[=desk =key ~]
|
||||
~
|
||||
==
|
||||
[%global-store-action [%del desk key]]
|
@ -1,10 +0,0 @@
|
||||
:: :global-store|enroll %desk /foo arena perm
|
||||
:: :global-store|enroll %kids /foo [%ship ~zod] `%r
|
||||
::
|
||||
/- *global-store
|
||||
:- %say
|
||||
|= $: ^
|
||||
[=desk =key =arena =perm ~]
|
||||
~
|
||||
==
|
||||
[%global-store-action [%enroll desk key arena perm]]
|
@ -1,9 +0,0 @@
|
||||
:: :global-store|lockdown %desk
|
||||
::
|
||||
/- *global-store
|
||||
:- %say
|
||||
|= $: ^
|
||||
[=desk ~]
|
||||
~
|
||||
==
|
||||
[%global-store-action [%lockdown desk]]
|
@ -1,9 +0,0 @@
|
||||
:: :global-store|lop %desk /key
|
||||
::
|
||||
/- *global-store
|
||||
:- %say
|
||||
|= $: ^
|
||||
[=desk =key ~]
|
||||
~
|
||||
==
|
||||
[%global-store-action [%lop desk key]]
|
@ -1,9 +0,0 @@
|
||||
:: :global-store|put %desk /key noun+!>(42)
|
||||
::
|
||||
/- *global-store
|
||||
:- %say
|
||||
|= $: ^
|
||||
[=desk =key =value ~]
|
||||
~
|
||||
==
|
||||
[%global-store-action [%put desk key value]]
|
@ -1,10 +0,0 @@
|
||||
:: :global-store|unroll %desk /foo arena
|
||||
:: :global-store|unroll %kids /foo [%ship ~zod]
|
||||
::
|
||||
/- *global-store
|
||||
:- %say
|
||||
|= $: ^
|
||||
[=desk =key =arena ~]
|
||||
~
|
||||
==
|
||||
[%global-store-action [%unroll desk key arena]]
|
9
desk/gen/gs/del.hoon
Normal file
9
desk/gen/gs/del.hoon
Normal file
@ -0,0 +1,9 @@
|
||||
:: :gs|del %desk /key
|
||||
::
|
||||
/- *gs
|
||||
:- %say
|
||||
|= $: ^
|
||||
[=desk =key ~]
|
||||
~
|
||||
==
|
||||
[%gs-action [%del desk key]]
|
10
desk/gen/gs/enroll.hoon
Normal file
10
desk/gen/gs/enroll.hoon
Normal file
@ -0,0 +1,10 @@
|
||||
:: :gs|enroll %desk /foo arena perm
|
||||
:: :gs|enroll %kids /foo [%ship ~zod] `%r
|
||||
::
|
||||
/- *gs
|
||||
:- %say
|
||||
|= $: ^
|
||||
[=desk =key =arena =perm ~]
|
||||
~
|
||||
==
|
||||
[%gs-action [%enroll desk key arena perm]]
|
9
desk/gen/gs/lockdown.hoon
Normal file
9
desk/gen/gs/lockdown.hoon
Normal file
@ -0,0 +1,9 @@
|
||||
:: :gs|lockdown %desk
|
||||
::
|
||||
/- *gs
|
||||
:- %say
|
||||
|= $: ^
|
||||
[=desk ~]
|
||||
~
|
||||
==
|
||||
[%gs-action [%lockdown desk]]
|
9
desk/gen/gs/lop.hoon
Normal file
9
desk/gen/gs/lop.hoon
Normal file
@ -0,0 +1,9 @@
|
||||
:: :gs|lop %desk /key
|
||||
::
|
||||
/- *gs
|
||||
:- %say
|
||||
|= $: ^
|
||||
[=desk =key ~]
|
||||
~
|
||||
==
|
||||
[%gs-action [%lop desk key]]
|
9
desk/gen/gs/put.hoon
Normal file
9
desk/gen/gs/put.hoon
Normal file
@ -0,0 +1,9 @@
|
||||
:: :gs|put %desk /key noun+!>(42)
|
||||
::
|
||||
/- *gs
|
||||
:- %say
|
||||
|= $: ^
|
||||
[=desk =key =value ~]
|
||||
~
|
||||
==
|
||||
[%gs-action [%put desk key value]]
|
10
desk/gen/gs/unroll.hoon
Normal file
10
desk/gen/gs/unroll.hoon
Normal file
@ -0,0 +1,10 @@
|
||||
:: :gs|unroll %desk /foo arena
|
||||
:: :gs|unroll %kids /foo [%ship ~zod]
|
||||
::
|
||||
/- *gs
|
||||
:- %say
|
||||
|= $: ^
|
||||
[=desk =key =arena ~]
|
||||
~
|
||||
==
|
||||
[%gs-action [%unroll desk key arena]]
|
@ -1,385 +0,0 @@
|
||||
/- *sss
|
||||
/+ *mip
|
||||
::
|
||||
|%
|
||||
++ mk-subs :: Create sub-map.
|
||||
|* [=(lake) paths=mold]
|
||||
-:+6:(da lake paths)
|
||||
::
|
||||
++ mk-pubs :: Create pub-map.
|
||||
|* [=(lake) paths=mold]
|
||||
-:+6:(du lake paths)
|
||||
::
|
||||
++ mk-mar :: Create mar.
|
||||
|* =(lake)
|
||||
|_ =(response:poke lake *)
|
||||
++ grow
|
||||
|%
|
||||
++ noun response
|
||||
--
|
||||
++ grab
|
||||
|%
|
||||
++ noun (response:poke lake *)
|
||||
--
|
||||
++ grad %noun
|
||||
--
|
||||
++ fled :: Like +sped but head is a path.
|
||||
|= vax=vase
|
||||
^- vase
|
||||
:_ q.vax
|
||||
%- ~(play ut p.vax)
|
||||
=- [%wtgr [%wtts - [%& 2]~] [%$ 1]]
|
||||
=/ pax ~| %path-none ;;(path -.q.vax)
|
||||
|- ^- spec
|
||||
?~ pax [%base %null]
|
||||
[%bccl ~[[%leaf %ta -.pax] $(pax +.pax)]]
|
||||
::
|
||||
++ zoom |= =noun ~| %need-path $/sss/;;(path noun)
|
||||
::
|
||||
++ da :: Manage subscriptions.
|
||||
|* [=(lake) paths=mold]
|
||||
=>
|
||||
|%
|
||||
+$ from (on-rock:poke lake paths)
|
||||
+$ into (response:poke lake paths)
|
||||
+$ result (request:poke paths)
|
||||
+$ fail [paths ship dude]
|
||||
+$ flow [=aeon stale=_| fail=_| =rock:lake]
|
||||
+$ subs [%0 (map [ship dude paths] (unit flow))]
|
||||
--
|
||||
|= $: sub=subs
|
||||
=bowl:gall
|
||||
result-type=type
|
||||
on-rock-type=type
|
||||
fail-type=type
|
||||
==
|
||||
=> .(sub +.sub)
|
||||
|%
|
||||
++ surf :: Subscribe to [ship dude path].
|
||||
|= which=[ship dude paths]
|
||||
^- (quip card:agent:gall subs)
|
||||
?+ flow=(~(get by sub) which) `0/sub
|
||||
~ [~[(pine which)] 0/(~(put by sub) which ~)]
|
||||
[~ ~] [~[(pine which)] 0/sub]
|
||||
[~ ~ [* %& * *]] [~[(scry `+(aeon.u.u.flow) which)] 0/sub]
|
||||
==
|
||||
++ quit (corl (lead %0) ~(del by sub)) :: Unsub from [ship dude path].
|
||||
++ read :: See current subscribed states.
|
||||
^- (map [ship dude paths] [stale=? fail=? =rock:lake])
|
||||
%- malt %+ murn ~(tap by sub)
|
||||
|= [key=[ship dude paths] val=(unit flow)]
|
||||
?~ val ~
|
||||
`[key +.u.val]
|
||||
:: :: Check poke-ack for errors.
|
||||
:: :: If an %sss-on-rock poke nacks,
|
||||
++ chit :: that state is flagged as failed.
|
||||
|= [[aeon=term ship=term dude=term path=paths] =sign:agent:gall]
|
||||
^- subs
|
||||
:- %0
|
||||
?> ?=(%poke-ack -.sign)
|
||||
?~ p.sign sub
|
||||
%+ ~(jab by sub) [(slav %p ship) dude path]
|
||||
|= (unit flow)
|
||||
=/ =flow (need +<)
|
||||
?> =(aeon.flow (slav %ud aeon))
|
||||
`flow(fail &)
|
||||
:: :: Check poke-ack for errors.
|
||||
:: :: If a scry request nacks,
|
||||
++ tell :: that state is flagged as stale.
|
||||
|= [[ship=term =dude aeon=term path=paths] =sign:agent:gall]
|
||||
^- (quip card:agent:gall subs)
|
||||
?> ?=(%poke-ack -.sign)
|
||||
?~ p.sign `0/sub
|
||||
=/ current [ship=(slav %p ship) dude=dude path=path]
|
||||
?+ flow=(~(get by sub) current) `0/sub
|
||||
[~ ~ *]
|
||||
=. stale.u.u.flow &
|
||||
:_ 0/(~(put by sub) current u.flow)
|
||||
~[(on-rock-poke current u.u.flow ~)]
|
||||
::
|
||||
[~ ~]
|
||||
:_ 0/(~(del by sub) current) :_ ~
|
||||
:* %pass (zoom surf-fail/aeon/ship/dude/path)
|
||||
%agent [our dap]:bowl
|
||||
%poke %sss-surf-fail fail-type ^- fail
|
||||
[path ship dude]:current
|
||||
==
|
||||
==
|
||||
:: :: Check if we're still interested
|
||||
:: :: in a wave. If no, no-op.
|
||||
:: :: If yes, scry.
|
||||
++ behn :: (See https://gist.github.com/belisarius222/7f8452bfea9b199c0ed717ab1778f35b)
|
||||
|= [ship=term =dude aeon=term path=paths]
|
||||
^- (list card:agent:gall)
|
||||
%- fall :_ ~ %- mole |.
|
||||
=/ ship (slav %p ship)
|
||||
=/ aeon (slav %ud aeon)
|
||||
?: (lte aeon aeon:(fall (~(got by sub) ship dude path) *flow)) ~
|
||||
~[(scry `aeon ship dude path)]
|
||||
::
|
||||
++ apply :: Handle response from publisher.
|
||||
|= res=(response:poke lake paths)
|
||||
^- (quip card:agent:gall subs)
|
||||
%- fall :_ `0/sub %- mole |.
|
||||
=* current [src.bowl dude.res path.res]
|
||||
=/ old=flow (fall (~(got by sub) current) *flow)
|
||||
?- type.res
|
||||
%tomb
|
||||
=/ =flow old(stale &)
|
||||
:_ 0/(~(put by sub) current `flow) :_ ~
|
||||
(on-rock-poke current flow ~)
|
||||
::
|
||||
%yore
|
||||
:_ 0/sub :_ ~
|
||||
(pine src.bowl dude.res path.res)
|
||||
::
|
||||
%nigh
|
||||
:_ 0/sub :_ ~
|
||||
(behn-s25 [dude aeon path]:res)
|
||||
::
|
||||
%scry
|
||||
=/ [wave=(unit wave:lake) =flow]
|
||||
?- what.res
|
||||
%rock ?> (gte aeon.res aeon.old)
|
||||
[~ [aeon.res | | rock.res]]
|
||||
%wave ?> =(aeon.res +(aeon.old))
|
||||
[`wave.res [aeon.res | | (wash:lake rock.old wave.res)]]
|
||||
==
|
||||
:_ 0/(~(put by sub) current `flow)
|
||||
:~ (on-rock-poke current flow wave)
|
||||
(scry `+(aeon.res) src.bowl dude.res path.res)
|
||||
==
|
||||
==
|
||||
::
|
||||
:: Non-public facing arms below
|
||||
::
|
||||
++ behn-s25
|
||||
|= [=dude =aeon path=noun]
|
||||
^- card:agent:gall
|
||||
:* %pass (zoom behn/(scot %p src.bowl)^dude^(scot %ud aeon)^path)
|
||||
%arvo %b %wait (add ~s25 now.bowl)
|
||||
==
|
||||
++ pine |= [ship dude paths] (scry ~ +<)
|
||||
++ scry
|
||||
|= [when=(unit aeon) who=ship which=dude where=paths]
|
||||
^- card:agent:gall
|
||||
=/ when ?~ when ~ (scot %ud u.when)
|
||||
:* %pass (zoom scry-request/(scot %p who)^which^when^where)
|
||||
%agent [who which]
|
||||
%poke %sss-to-pub :- result-type ^- result
|
||||
[where dap.bowl ^when]
|
||||
==
|
||||
++ on-rock-poke
|
||||
|= [[=ship =dude path=paths] flow wave=(unit wave:lake)]
|
||||
^- card:agent:gall
|
||||
:* %pass (zoom on-rock/(scot %ud aeon)^(scot %p ship)^dude^path)
|
||||
%agent [our dap]:bowl
|
||||
%poke %sss-on-rock on-rock-type ^- from
|
||||
[path ship dude stale fail rock wave]
|
||||
==
|
||||
--
|
||||
++ du :: Manage publications.
|
||||
|* [=(lake) paths=mold]
|
||||
=>
|
||||
|%
|
||||
+$ into (request:poke paths)
|
||||
+$ result (response:poke lake paths)
|
||||
+$ rule [rocks=_1 waves=_5] :: Retention policy
|
||||
+$ tide
|
||||
$: rok=((mop aeon rock:lake) gte)
|
||||
wav=((mop aeon wave:lake) lte)
|
||||
rul=rule
|
||||
mem=(mip ship dude @da)
|
||||
==
|
||||
+$ buoy
|
||||
$: tid=$~(*tide $@(aeon tide))
|
||||
alo=(unit (set ship))
|
||||
==
|
||||
+$ pubs [%0 (map paths buoy)]
|
||||
--
|
||||
|= [pub=pubs =bowl:gall result-type=type]
|
||||
=> .(pub +.pub)
|
||||
=* rok ((on aeon rock:lake) gte)
|
||||
=* wav ((on aeon wave:lake) lte)
|
||||
|%
|
||||
++ rule :: Set new retention policy.
|
||||
|= [path=paths =^rule]
|
||||
^- pubs
|
||||
:- %0
|
||||
%+ ~(jab by pub) path
|
||||
|= =buoy
|
||||
?@ tid.buoy buoy
|
||||
buoy(tid (form tid.buoy(rul rule)))
|
||||
::
|
||||
++ wipe :: Create new rock and wipe rest.
|
||||
|= path=paths
|
||||
^- pubs
|
||||
:- %0
|
||||
%+ ~(jab by pub) path
|
||||
|= =buoy
|
||||
?@ tid.buoy buoy
|
||||
%* . buoy(tid (form tid.buoy(rul [0 1])))
|
||||
rul.tid rul.tid.buoy
|
||||
wav.tid ~
|
||||
==
|
||||
++ give :: Give a wave on a path.
|
||||
|= [path=paths =wave:lake]
|
||||
^- (quip card:agent:gall pubs)
|
||||
?~ ((soft ^path) path) ~| %need-path !!
|
||||
=/ buoy (~(gut by pub) path *buoy)
|
||||
=? buoy ?=(@ tid.buoy)
|
||||
%*(. buoy(tid *tide) rok.tid (put:rok ~ +(tid.buoy) *rock:lake))
|
||||
?> ?=(^ tid.buoy)
|
||||
=* tide tid.buoy
|
||||
=/ next=aeon +((latest tide))
|
||||
:- %+ murn ~(tap bi mem.tide)
|
||||
|= [=ship =dude =@da]
|
||||
?: (lth da now.bowl) ~
|
||||
`(send scry/wave/wave ship dude next path)
|
||||
:- %0
|
||||
%+ ~(put by pub) path
|
||||
=/ last=[=aeon =rock:lake] (fall (pry:rok rok.tide) *[key val]:rok)
|
||||
=. wav.tide (put:wav wav.tide next wave)
|
||||
=. mem.tide ~
|
||||
?. =(next (add aeon.last waves.rul.tide)) buoy
|
||||
buoy(tid (form tide))
|
||||
::
|
||||
++ fork :: Fork a pub into an empty path.
|
||||
|= [from=paths to=paths]
|
||||
^- pubs
|
||||
:- %0
|
||||
?< (~(has by pub) to)
|
||||
(~(put by pub) to (~(got by pub) from))
|
||||
::
|
||||
++ copy :: Fork a sub into an empty path.
|
||||
|= [sub=_(mk-subs lake *) from=[ship dude *] to=paths]
|
||||
^- pubs
|
||||
:- %0
|
||||
?< (~(has by pub) to)
|
||||
%+ ~(put by pub) to
|
||||
%* . *$<(aeon buoy)
|
||||
rok.tid (put:rok ~ [aeon rock]:(need (~(got by +:sub) from)))
|
||||
==
|
||||
::
|
||||
++ perm :: Change permissions with gate.
|
||||
|= [where=(list paths) diff=$-((unit (set ship)) (unit (set ship)))]
|
||||
^- pubs
|
||||
%+ edit where
|
||||
|= =buoy
|
||||
=/ new=_alo.buoy (diff alo.buoy)
|
||||
?@ tid.buoy buoy(alo new)
|
||||
%= buoy
|
||||
alo new
|
||||
mem.tid ?~ new mem.tid.buoy
|
||||
%. mem.tid.buoy
|
||||
~(int by (malt (turn ~(tap in u.new) (late *(map @ @)))))
|
||||
==
|
||||
++ public (curr perm _~) :: Make list of paths public.
|
||||
++ secret (curr perm _`~) :: Make list of paths secret.
|
||||
:: :: Block ships from paths.
|
||||
++ block :: No-ops on public paths.
|
||||
|= [who=(list ship) whence=(list paths)]
|
||||
^- pubs
|
||||
%+ perm whence
|
||||
|= old=(unit (set ship))
|
||||
?~ old ~ `(~(dif in u.old) (sy who))
|
||||
:: :: Allow ships to paths.
|
||||
++ allow :: Any public paths will no-op.
|
||||
|= [who=(list ship) where=(list paths)]
|
||||
^- pubs
|
||||
%+ perm where
|
||||
|= old=(unit (set ship))
|
||||
?~ old ~ `(~(gas in u.old) who)
|
||||
:: :: Kill a list of paths, i.e. tell
|
||||
++ kill :: subs to not expect updates.
|
||||
(curr edit |=(=buoy buoy(tid (latest tid.buoy))))
|
||||
:: :: Reopen list of killed paths.
|
||||
++ read :: See current published states.
|
||||
^- (map paths [allowed=(unit (set ship)) =rock:lake])
|
||||
%- malt %+ murn ~(tap by pub)
|
||||
|= [path=paths =buoy]
|
||||
^- (unit [paths (unit (set ship)) rock:lake])
|
||||
?@ tide=tid.buoy ~
|
||||
:^ ~ path alo.buoy =< rock
|
||||
=/ snap=[=aeon =rock:lake] (fall (pry:rok rok.tide) *[key val]:rok)
|
||||
%+ roll (tap:wav (lot:wav wav.tide `aeon.snap ~))
|
||||
|= [[=aeon =wave:lake] =_snap]
|
||||
?. =(aeon +(aeon.snap)) snap
|
||||
[aeon (wash:lake rock.snap wave)]
|
||||
::
|
||||
++ apply :: Handle request from subscriber.
|
||||
|= req=(request:poke paths)
|
||||
^- (quip card:agent:gall pubs)
|
||||
=/ =buoy (~(gut by pub) path.req *buoy)
|
||||
?< &(?=(^ alo.buoy) !(~(has in u.alo.buoy) src.bowl))
|
||||
?@ tid.buoy
|
||||
:_ 0/pub :_ ~
|
||||
(send tomb/~ src.bowl dude.req tid.buoy path.req)
|
||||
?~ when.req
|
||||
=/ last (fall (pry:rok rok.tid.buoy) *[=key =val]:rok)
|
||||
:_ 0/pub :_ ~
|
||||
(send scry/rock/val.last src.bowl dude.req key.last path.req)
|
||||
?^ dat=(get:wav wav.tid.buoy u.when.req)
|
||||
:_ 0/pub :_ ~
|
||||
(send scry/wave/u.dat src.bowl [dude u.when path]:req)
|
||||
?: %+ lte u.when.req
|
||||
key::(fall (ram:wav wav.tid.buoy) (pry:rok rok.tid.buoy) [=key val]:wav)
|
||||
:_ 0/pub :_ ~
|
||||
(send yore/~ src.bowl [dude u.when path]:req)
|
||||
?> =(u.when.req +((latest tid.buoy)))
|
||||
:- ~[(send nigh/~ src.bowl [dude u.when path]:req)]
|
||||
:- %0
|
||||
%+ ~(put by pub) path.req
|
||||
%= buoy
|
||||
mem.tid (~(put bi mem.tid.buoy) src.bowl dude.req (add ~s25 now.bowl))
|
||||
==
|
||||
::
|
||||
:: Non-public facing arms below
|
||||
::
|
||||
++ send
|
||||
|= [payload=_|3:*(response:poke lake paths) =ship =dude =aeon path=paths]
|
||||
^- card:agent:gall
|
||||
=* mark (cat 3 %sss- name:lake)
|
||||
:* %pass (zoom scry-response/(scot %p ship)^dude^(scot %ud aeon)^path)
|
||||
%agent [ship dude]
|
||||
%poke mark result-type ^- (response:poke lake paths)
|
||||
[path dap.bowl aeon payload]
|
||||
==
|
||||
++ latest
|
||||
|= =$@(aeon tide)
|
||||
^- aeon
|
||||
?@ tide tide
|
||||
%+ max (fall (bind (pry:rok rok.tide) head) 0)
|
||||
(fall (bind (ram:wav wav.tide) head) 0)
|
||||
::
|
||||
++ edit
|
||||
|= [ps=(list paths) edit=$-(buoy buoy)]
|
||||
^- pubs
|
||||
:- %0
|
||||
%- ~(rep in (sy ps))
|
||||
|= [path=paths =_pub]
|
||||
%- fall :_ pub %- mole |.
|
||||
(~(jab by pub) path edit)
|
||||
::
|
||||
++ form
|
||||
|= =tide
|
||||
^+ tide
|
||||
=/ max-rock=[=aeon =rock:lake] (fall (pry:rok rok.tide) *[key val]:rok)
|
||||
=/ max-wave (fall (bind (ram:wav wav.tide) head) 0)
|
||||
=. rok.tide
|
||||
%+ gas:rok +<-:gas:rok
|
||||
%- tab:rok :_ [~ +(rocks.rul.tide)]
|
||||
?: ?| =(waves.rul.tide 0)
|
||||
(lth max-wave (add aeon.max-rock waves.rul.tide))
|
||||
==
|
||||
rok.tide
|
||||
%+ put:rok rok.tide
|
||||
%+ roll (tab:wav wav.tide `aeon.max-rock max-wave)
|
||||
|: [*[now=aeon =wave:lake] `[prev=aeon =rock:lake]`max-rock]
|
||||
~| %aeon-awry
|
||||
?> =(now +(prev))
|
||||
[now (wash:lake rock wave)]
|
||||
~| %rock-zero
|
||||
tide(wav (lot:wav wav.tide (bind (ram:rok rok.tide) |=([r=@ *] (dec r))) ~))
|
||||
--
|
||||
--
|
@ -1,3 +1,3 @@
|
||||
/- *global-store
|
||||
/- *gs
|
||||
/+ sss
|
||||
(mk-mar:sss action)
|
@ -1,3 +1,3 @@
|
||||
/- *global-store
|
||||
/- *gs
|
||||
/+ sss
|
||||
(mk-mar:sss update)
|
@ -1,4 +1,4 @@
|
||||
:: /sur/global-store.hoon
|
||||
:: /sur/gs.hoon
|
||||
:::: ~lagrev-nocfep & ~midden-fabler
|
||||
:: Version ~2023.11.9
|
||||
::
|
||||
@ -34,7 +34,8 @@
|
||||
::
|
||||
+$ update
|
||||
$% [%desk (map key value)]
|
||||
[%key (trel desk key ?)]
|
||||
[%has-desk (pair desk ?)]
|
||||
[%has-key (trel desk key ?)]
|
||||
[%value p=(unit value)]
|
||||
==
|
||||
--
|
@ -1,43 +0,0 @@
|
||||
|%
|
||||
++ lake
|
||||
|$ [rock wave]
|
||||
$_ ^?
|
||||
|%
|
||||
++ name *term
|
||||
+$ rock ^rock
|
||||
+$ wave ^wave
|
||||
++ wash |~ [rock wave] *rock
|
||||
--
|
||||
+$ aeon @ud
|
||||
+$ dude dude:agent:gall
|
||||
+$ what ?(%rock %wave)
|
||||
++ poke
|
||||
|%
|
||||
++ request
|
||||
|* paths=mold
|
||||
$: path=paths
|
||||
=dude
|
||||
when=(unit aeon)
|
||||
==
|
||||
++ response
|
||||
|* [=(lake) paths=mold]
|
||||
$: path=paths
|
||||
=dude
|
||||
=aeon
|
||||
$% [type=?(%nigh %yore %tomb) ~]
|
||||
$: type=%scry
|
||||
$% [what=%rock =rock:lake]
|
||||
[what=%wave =wave:lake]
|
||||
== == == ==
|
||||
++ on-rock
|
||||
|* [=(lake) paths=mold]
|
||||
$: path=paths
|
||||
src=ship
|
||||
from=dude
|
||||
stale=?
|
||||
fail=?
|
||||
=rock:lake
|
||||
wave=(unit wave:lake)
|
||||
==
|
||||
--
|
||||
--
|
@ -1,4 +1,4 @@
|
||||
/- *global-store
|
||||
/- *gs
|
||||
|%
|
||||
++ name %update
|
||||
+$ rock (unit value)
|
||||
|
@ -1,19 +1,19 @@
|
||||
:: /tests/global-store.hoon
|
||||
:: /tests/gs.hoon
|
||||
:::: ~lagrev-nocfep
|
||||
:: Version ~2023.7.28
|
||||
::
|
||||
/- gs=global-store
|
||||
/- gs=gs
|
||||
/+ *test, *mip
|
||||
/= agent /app/global-store
|
||||
/= agent /app/gs
|
||||
|%
|
||||
:: Build an example bowl manually.
|
||||
::
|
||||
++ bowl
|
||||
|= run=@ud
|
||||
^- bowl:gall
|
||||
:* [~zod ~zod %global-store] :: (our src dap)
|
||||
:* [~zod ~zod %gs] :: (our src dap)
|
||||
[~ ~] :: (wex sup)
|
||||
[run `@uvJ`(shax run) *time [~zod %global-store ud+run]]
|
||||
[run `@uvJ`(shax run) *time [~zod %gs ud+run]]
|
||||
:: (act eny now byk)
|
||||
==
|
||||
:: Build a reference state mold.
|
||||
@ -28,7 +28,7 @@
|
||||
|%
|
||||
++ test-add-single-desk
|
||||
=| run=@ud
|
||||
=^ move agent (~(on-poke agent (bowl run)) %global-store-action !>([%let %surf]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %gs-action !>([%let %surf]))
|
||||
=+ !<(state=state-zero on-save:agent)
|
||||
%+ expect-eq
|
||||
!> :* %zero
|
||||
@ -39,8 +39,8 @@
|
||||
!> state
|
||||
++ test-add-two-desks
|
||||
=| run=@ud
|
||||
=^ move agent (~(on-poke agent (bowl run)) %global-store-action !>([%let %surf]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %global-store-action !>([%let %turf]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %gs-action !>([%let %surf]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %gs-action !>([%let %turf]))
|
||||
=+ !<(state=state-zero on-save:agent)
|
||||
%+ expect-eq
|
||||
=| sto=store:gs
|
||||
@ -54,9 +54,9 @@
|
||||
!> state
|
||||
++ test-delete-desk
|
||||
=| run=@ud
|
||||
=^ move agent (~(on-poke agent (bowl run)) %global-store-action !>([%let %surf]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %global-store-action !>([%let %turf]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %global-store-action !>([%lie %surf]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %gs-action !>([%let %surf]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %gs-action !>([%let %turf]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %gs-action !>([%lie %surf]))
|
||||
=+ !<(state=state-zero on-save:agent)
|
||||
%+ expect-eq
|
||||
=| sto=store:gs
|
||||
@ -71,10 +71,10 @@
|
||||
!> state
|
||||
++ test-add-values-to-desk
|
||||
=| run=@ud
|
||||
=^ move agent (~(on-poke agent (bowl run)) %global-store-action !>([%let %home]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %global-store-action !>([%put %home %city 'Champaign']))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %global-store-action !>([%put %home %state 'Illinois']))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %global-store-action !>([%put %home %zip '61801']))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %gs-action !>([%let %home]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %gs-action !>([%put %home %city 'Champaign']))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %gs-action !>([%put %home %state 'Illinois']))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %gs-action !>([%put %home %zip '61801']))
|
||||
=+ !<(state=state-zero on-save:agent)
|
||||
%+ expect-eq
|
||||
=| sto=store:gs
|
||||
@ -90,12 +90,12 @@
|
||||
!> state
|
||||
++ test-delete-values-in-desk
|
||||
=| run=@ud
|
||||
=^ move agent (~(on-poke agent (bowl run)) %global-store-action !>([%let %home]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %global-store-action !>([%put %home %city 'Champaign']))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %global-store-action !>([%put %home %state 'Illinois']))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %global-store-action !>([%put %home %zip '61801']))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %global-store-action !>([%del %home %city]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %global-store-action !>([%del %home %zip]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %gs-action !>([%let %home]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %gs-action !>([%put %home %city 'Champaign']))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %gs-action !>([%put %home %state 'Illinois']))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %gs-action !>([%put %home %zip '61801']))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %gs-action !>([%del %home %city]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %gs-action !>([%del %home %zip]))
|
||||
=+ !<(state=state-zero on-save:agent)
|
||||
%+ expect-eq
|
||||
=| sto=store:gs
|
||||
@ -109,10 +109,10 @@
|
||||
!> state
|
||||
++ test-set-perms
|
||||
=| run=@ud
|
||||
=^ move agent (~(on-poke agent (bowl run)) %global-store-action !>([%mode %public %r]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %global-store-action !>([%mode %whitelist %w]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %global-store-action !>([%mode %team %w]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %global-store-action !>([%mode %me %w]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %gs-action !>([%mode %public %r]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %gs-action !>([%mode %whitelist %w]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %gs-action !>([%mode %team %w]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %gs-action !>([%mode %me %w]))
|
||||
=+ !<(state=state-zero on-save:agent)
|
||||
%+ expect-eq
|
||||
=| per=perms:gs
|
||||
@ -130,11 +130,11 @@
|
||||
::++ test-blacklist
|
||||
++ test-lockdown
|
||||
=| run=@ud
|
||||
=^ move agent (~(on-poke agent (bowl run)) %global-store-action !>([%mode %public %r]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %global-store-action !>([%mode %whitelist %w]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %global-store-action !>([%mode %team %w]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %global-store-action !>([%mode %me %w]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %global-store-action !>([%lockdown ~]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %gs-action !>([%mode %public %r]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %gs-action !>([%mode %whitelist %w]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %gs-action !>([%mode %team %w]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %gs-action !>([%mode %me %w]))
|
||||
=^ move agent (~(on-poke agent (bowl run)) %gs-action !>([%lockdown ~]))
|
||||
=+ !<(state=state-zero on-save:agent)
|
||||
%+ expect-eq
|
||||
=| per=perms:gs
|
||||
|
Loading…
Reference in New Issue
Block a user