A DataScript database on a persistent ref (PDT 2 phase 2, group D;
srad/agentspaces-pdt2.md §3.1). datascript-conn returns a DataScript conn
whose d/transact! goes through a db ref of the system's ref space, so the
database survives a restart and every member of the group reads it:
(def conn (pdt-ds/datascript-conn system "pdt" "graph" schema {}))
(d/transact! conn [{:person/name "Ada"}]) ; writes a head
(d/q '[:find ?n :where [_ :person/name ?n]] @conn)
tx-data joins the tail, a dn node that the head carries
inline while it fits; past 128 tail datoms, or :fold-every (30 s) after
the last fold, the conn folds instead: the adapter writes the dirty paths
of the three indexes and the next head names a root with no tail (P2-D-03).PRef.v 2 of kind db; the ref is linear unless the
facade's :pdt {:refs {name {:mode :multi}}} says otherwise, and two heads
of a multi ref meet in the datom merge of agentspaces.datascript.merge.::moved) and holds the new head, and a multi conn
merges the transaction with it by datoms.:tx-data is the change and whose
:tx-meta names the root under :agentspaces.datascript/remote.Options: :fold-every (a duration, "30s"), :instant (:date, the
default, or :instant: the Java type an instant reads back as), and
:await-head (a duration to wait at open for a head of the ref to arrive;
none by default).
A DataScript database on a persistent ref (PDT 2 phase 2, group D;
srad/agentspaces-pdt2.md §3.1). `datascript-conn` returns a DataScript conn
whose `d/transact!` goes through a `db` ref of the system's ref space, so the
database survives a restart and every member of the group reads it:
(def conn (pdt-ds/datascript-conn system "pdt" "graph" schema {}))
(d/transact! conn [{:person/name "Ada"}]) ; writes a head
(d/q '[:find ?n :where [_ :person/name ?n]] @conn)
- A transaction's `tx-data` joins the tail, a `dn` node that the head carries
inline while it fits; past 128 tail datoms, or `:fold-every` (30 s) after
the last fold, the conn folds instead: the adapter writes the dirty paths
of the three indexes and the next head names a root with no tail (P2-D-03).
- Every head is `PRef.v` 2 of kind `db`; the ref is linear unless the
facade's `:pdt {:refs {name {:mode :multi}}}` says otherwise, and two heads
of a multi ref meet in the datom merge of `agentspaces.datascript.merge`.
- Opening reads the head's root, and its tail when it has one, and nothing
else; a query reads the index nodes on its path (P2-D-04, P2-D-05).
- A transaction first brings the conn to the newest head its ref holds; when
another writer moves the ref before the write, a linear conn refuses the
transaction (ex-data `::moved`) and holds the new head, and a multi conn
merges the transaction with it by datoms.
- A head another member writes replaces the conn's database, and the conn's
listeners hear it as a report whose `:tx-data` is the change and whose
`:tx-meta` names the root under `:agentspaces.datascript/remote`.
Options: `:fold-every` (a duration, "30s"), `:instant` (`:date`, the
default, or `:instant`: the Java type an instant reads back as), and
`:await-head` (a duration to wait at open for a head of the ref to arrive;
none by default).(close! conn)Stops the conn's fold timer and its watch of the ref; the database stays in the ref.
Stops the conn's fold timer and its watch of the ref; the database stays in the ref.
(datascript-conn system space name schema)(datascript-conn system
space
name
schema
{:keys [fold-every instant]
wait :await-head
:or {fold-every "30s" instant :date}})A DataScript conn on the db ref name of the system's ref space space
(P2-D-03): the system must be a fleet/start system with :pdt, whose ref
space is space. schema is DataScript's schema; see the namespace doc for
opts. Close it with close!.
A DataScript conn on the `db` ref `name` of the system's ref space `space` (P2-D-03): the system must be a `fleet/start` system with `:pdt`, whose ref space is `space`. `schema` is DataScript's schema; see the namespace doc for `opts`. Close it with `close!`.
(fold! conn)Folds the conn's tail into its indexes now and writes the head; a no-op when the tail is empty. Returns the root written, or nil.
Folds the conn's tail into its indexes now and writes the head; a no-op when the tail is empty. Returns the root written, or nil.
(stats conn)The conn's counters: :reads (every node it read: roots, tails, and index nodes), :root, and :tail (the datoms not yet folded).
The conn's counters: :reads (every node it read: roots, tails, and index nodes), :root, and :tail (the datoms not yet folded).
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |