Public API of Crux.
Public API of Crux.
(db node)
(db node valid-time)
(db node valid-time transaction-time)
When a valid time is specified then returned db value contains only those documents whose valid time is before the specified time.
When both valid and transaction time are specified returns a db value as of the valid time and the latest transaction time indexed at or before the specified transaction time.
If the node hasn't yet indexed a transaction at or past the given transaction-time, this throws NodeOutOfSyncException
When a valid time is specified then returned db value contains only those documents whose valid time is before the specified time. When both valid and transaction time are specified returns a db value as of the valid time and the latest transaction time indexed at or before the specified transaction time. If the node hasn't yet indexed a transaction at or past the given transaction-time, this throws NodeOutOfSyncException
(open-db node)
(open-db node valid-time)
(open-db node valid-time transaction-time)
When a valid time is specified then returned db value contains only those documents whose valid time is before the specified time.
When both valid and transaction time are specified returns a db value as of the valid time and the latest transaction time indexed at or before the specified transaction time.
If the node hasn't yet indexed a transaction at or past the given transaction-time, this throws NodeOutOfSyncException
This DB opens up shared resources to make multiple requests faster - it must
be .close
d when you've finished using it (for example, in a with-open
block)
When a valid time is specified then returned db value contains only those documents whose valid time is before the specified time. When both valid and transaction time are specified returns a db value as of the valid time and the latest transaction time indexed at or before the specified transaction time. If the node hasn't yet indexed a transaction at or past the given transaction-time, this throws NodeOutOfSyncException This DB opens up shared resources to make multiple requests faster - it must be `.close`d when you've finished using it (for example, in a `with-open` block)
(new-api-client url)
(new-api-client url opts)
Creates a new remote API client ICruxAPI.
The remote client requires valid and transaction time to be specified for all calls to db
.
NOTE: Requires either clj-http or http-kit on the classpath, See https://opencrux.com/reference/http.html for more information.
url the URL to a Crux HTTP end-point. (OPTIONAL) auth-supplier a supplier function which provides an auth token string for the Crux HTTP end-point.
returns a remote API client.
Creates a new remote API client ICruxAPI. The remote client requires valid and transaction time to be specified for all calls to `db`. NOTE: Requires either clj-http or http-kit on the classpath, See https://opencrux.com/reference/http.html for more information. url the URL to a Crux HTTP end-point. (OPTIONAL) auth-supplier a supplier function which provides an auth token string for the Crux HTTP end-point. returns a remote API client.
(new-ingest-client options)
Starts an ingest client for transacting into Crux without running a full local node with index.
Accepts a map, or a JSON/EDN file or classpath resource.
See https://opencrux.com/reference/configuration.html for details.
Returns a crux.api.ICruxIngestAPI component that implements java.io.Closeable.
Latter allows the node to be stopped by calling (.close node)
.
Starts an ingest client for transacting into Crux without running a full local node with index. Accepts a map, or a JSON/EDN file or classpath resource. See https://opencrux.com/reference/configuration.html for details. Returns a crux.api.ICruxIngestAPI component that implements java.io.Closeable. Latter allows the node to be stopped by calling `(.close node)`.
Provides API access to Crux async ingestion.
Provides API access to Crux async ingestion.
(submit-tx-async node tx-ops)
Writes transactions to the log for processing tx-ops datalog style transactions. Non-blocking. Returns a deref with map with details about the submitted transaction, including tx-time and tx-id.
Writes transactions to the log for processing tx-ops datalog style transactions. Non-blocking. Returns a deref with map with details about the submitted transaction, including tx-time and tx-id.
Represents the database as of a specific valid and transaction time.
Represents the database as of a specific valid and transaction time.
(transaction-time db)
returns the time of the latest transaction applied to this db value. If a tx time was specified when db value was acquired then returns the specified time.
returns the time of the latest transaction applied to this db value. If a tx time was specified when db value was acquired then returns the specified time.
(open-entity-history db eid sort-order)
(open-entity-history
db
eid
sort-order
{:keys [with-docs? with-corrections?]
{start-vt :crux.db/valid-time start-tt :crux.tx/tx-time} :start
{end-vt :crux.db/valid-time end-tt :crux.tx/tx-time} :end})
Lazily retrieves entity history for the given entity.
Don't forget to close the cursor when you've consumed enough history!
See entity-history
for all the options
Lazily retrieves entity history for the given entity. Don't forget to close the cursor when you've consumed enough history! See `entity-history` for all the options
(entity db eid)
queries a document map for an entity. eid is an object which can be coerced into an entity id. returns the entity document map.
queries a document map for an entity. eid is an object which can be coerced into an entity id. returns the entity document map.
(q db query)
q[uery] a Crux db.
query param is a datalog query in map, vector or string form.
This function will return a set of result tuples if you do not specify :order-by
, :limit
or :offset
;
otherwise, it will return a vector of result tuples.
q[uery] a Crux db. query param is a datalog query in map, vector or string form. This function will return a set of result tuples if you do not specify `:order-by`, `:limit` or `:offset`; otherwise, it will return a vector of result tuples.
(open-q db query)
lazily q[uery] a Crux db. query param is a datalog query in map, vector or string form.
This function returns a Cursor of result tuples - once you've consumed
as much of the sequence as you need to, you'll need to .close
the sequence.
A common way to do this is using with-open
:
(with-open [res (crux/open-q db '{:find [...] :where [...]})] (doseq [row (iterator-seq res)] ...))
Once the sequence is closed, attempting to iterate it is undefined.
lazily q[uery] a Crux db. query param is a datalog query in map, vector or string form. This function returns a Cursor of result tuples - once you've consumed as much of the sequence as you need to, you'll need to `.close` the sequence. A common way to do this is using `with-open`: (with-open [res (crux/open-q db '{:find [...] :where [...]})] (doseq [row (iterator-seq res)] ...)) Once the sequence is closed, attempting to iterate it is undefined.
(entity-tx db eid)
returns the transaction details for an entity. Details include tx-id and tx-time. eid is an object that can be coerced into an entity id.
returns the transaction details for an entity. Details include tx-id and tx-time. eid is an object that can be coerced into an entity id.
(with-tx db tx-ops)
Returns a new db value with the tx-ops speculatively applied. The tx-ops will only be visible in the value returned from this function - they're not submitted to the cluster, nor are they visible to any other database value in your application. If the transaction doesn't commit (eg because of a failed 'match'), this function returns nil.
Returns a new db value with the tx-ops speculatively applied. The tx-ops will only be visible in the value returned from this function - they're not submitted to the cluster, nor are they visible to any other database value in your application. If the transaction doesn't commit (eg because of a failed 'match'), this function returns nil.
(valid-time db)
returns the valid time of the db. If valid time wasn't specified at the moment of the db value retrieval then valid time will be time of the latest transaction.
returns the valid time of the db. If valid time wasn't specified at the moment of the db value retrieval then valid time will be time of the latest transaction.
(entity-history db eid sort-order)
(entity-history db
eid
sort-order
{:keys [with-docs? with-corrections?]
{start-vt :crux.db/valid-time start-tt :crux.tx/tx-time} :start
{end-vt :crux.db/valid-time end-tt :crux.tx/tx-time} :end})
Eagerly retrieves entity history for the given entity.
Options:
sort-order
(parameter): #{:asc :desc}
:with-docs?
: specifies whether to include documents in the entries:with-corrections?
: specifies whether to include bitemporal corrections in the sequence, sorted first by valid-time, then transaction-time.:start
(nested map, inclusive, optional): the :crux.db/valid-time
and :crux.tx/tx-time
to start at.:end
(nested map, exclusive, optional): the :crux.db/valid-time
and :crux.tx/tx-time
to stop at.No matter what :start
and :end
parameters you specify, you won't receive
results later than the valid-time and transact-time of this DB value.
Each entry in the result contains the following keys:
:crux.db/valid-time
,:crux.db/tx-time
,:crux.tx/tx-id
,:crux.db/content-hash
:crux.db/doc
(see with-docs?
).Eagerly retrieves entity history for the given entity. Options: * `sort-order` (parameter): `#{:asc :desc}` * `:with-docs?`: specifies whether to include documents in the entries * `:with-corrections?`: specifies whether to include bitemporal corrections in the sequence, sorted first by valid-time, then transaction-time. * `:start` (nested map, inclusive, optional): the `:crux.db/valid-time` and `:crux.tx/tx-time` to start at. * `:end` (nested map, exclusive, optional): the `:crux.db/valid-time` and `:crux.tx/tx-time` to stop at. No matter what `:start` and `:end` parameters you specify, you won't receive results later than the valid-time and transact-time of this DB value. Each entry in the result contains the following keys: * `:crux.db/valid-time`, * `:crux.db/tx-time`, * `:crux.tx/tx-id`, * `:crux.db/content-hash` * `:crux.db/doc` (see `with-docs?`).
Provides API access to Crux ingestion.
Provides API access to Crux ingestion.
(open-tx-log this after-tx-id with-ops?)
Reads the transaction log. Optionally includes operations, which allow the contents under the :crux.api/tx-ops key to be piped into (submit-tx tx-ops) of another Crux instance.
after-tx-id optional transaction id to start after. with-ops? should the operations with documents be included?
Returns an iterator of the TxLog
Reads the transaction log. Optionally includes operations, which allow the contents under the :crux.api/tx-ops key to be piped into (submit-tx tx-ops) of another Crux instance. after-tx-id optional transaction id to start after. with-ops? should the operations with documents be included? Returns an iterator of the TxLog
(submit-tx node tx-ops)
Writes transactions to the log for processing tx-ops datalog style transactions. Returns a map with details about the submitted transaction, including tx-time and tx-id.
Writes transactions to the log for processing tx-ops datalog style transactions. Returns a map with details about the submitted transaction, including tx-time and tx-id.
Provides API access to Crux.
Provides API access to Crux.
(await-tx-time node tx-time)
(await-tx-time node tx-time timeout)
Blocks until the node has indexed a transaction that is past the supplied txTime. Will throw on timeout. The returned date is the latest index time when this node has caught up as of this call.
Blocks until the node has indexed a transaction that is past the supplied txTime. Will throw on timeout. The returned date is the latest index time when this node has caught up as of this call.
(await-tx node tx)
(await-tx node tx timeout)
Blocks until the node has indexed a transaction that is at or past the supplied tx. Will throw on timeout. Returns the most recent tx indexed by the node.
Blocks until the node has indexed a transaction that is at or past the supplied tx. Will throw on timeout. Returns the most recent tx indexed by the node.
(tx-committed? node submitted-tx)
Checks if a submitted tx was successfully committed.
submitted-tx must be a map returned from submit-tx
.
Returns true if the submitted transaction was committed,
false if the transaction was not committed, and throws NodeOutOfSyncException
if the node has not yet indexed the transaction.
Checks if a submitted tx was successfully committed. submitted-tx must be a map returned from `submit-tx`. Returns true if the submitted transaction was committed, false if the transaction was not committed, and throws `NodeOutOfSyncException` if the node has not yet indexed the transaction.
(latest-completed-tx node)
Returns the latest transaction to have been indexed by this node.
Returns the latest transaction to have been indexed by this node.
(attribute-stats node)
Returns frequencies map for indexed attributes
Returns frequencies map for indexed attributes
(sync node)
(sync node timeout)
Blocks until the node has caught up indexing to the latest tx available at the time this method is called. Will throw an exception on timeout. The returned date is the latest transaction time indexed by this node. This can be used as the second parameter in (db valid-time, transaction-time) for consistent reads.
timeout – max time to wait, can be nil for the default. Returns the latest known transaction time.
Blocks until the node has caught up indexing to the latest tx available at the time this method is called. Will throw an exception on timeout. The returned date is the latest transaction time indexed by this node. This can be used as the second parameter in (db valid-time, transaction-time) for consistent reads. timeout – max time to wait, can be nil for the default. Returns the latest known transaction time.
(recent-queries node)
Returns a list of recently completed/failed queries
Returns a list of recently completed/failed queries
(slowest-queries node)
Returns a list of slowest completed/failed queries ran on the node
Returns a list of slowest completed/failed queries ran on the node
(listen node event-opts f)
Attaches a listener to Crux's event bus.
event-opts
should contain :crux/event-type
, along with any other options the event-type requires.
We currently only support one public event-type: :crux/indexed-tx
.
Supplying :with-tx-ops? true
will include the transaction's operations in the event passed to f
.
(.close ...)
the return value to detach the listener.
This is an experimental API, subject to change.
Attaches a listener to Crux's event bus. `event-opts` should contain `:crux/event-type`, along with any other options the event-type requires. We currently only support one public event-type: `:crux/indexed-tx`. Supplying `:with-tx-ops? true` will include the transaction's operations in the event passed to `f`. `(.close ...)` the return value to detach the listener. This is an experimental API, subject to change.
(status node)
Returns the status of this node as a map.
Returns the status of this node as a map.
(active-queries node)
Returns a list of currently running queries
Returns a list of currently running queries
(latest-submitted-tx node)
Returns the latest transaction to have been submitted to this cluster
Returns the latest transaction to have been submitted to this cluster
(start-node options)
NOTE: requires any dependencies on the classpath that the Crux modules may need.
Accepts a map, or a JSON/EDN file or classpath resource.
See https://opencrux.com/reference/configuration.html for details.
Returns a node which implements ICruxAPI and java.io.Closeable.
Latter allows the node to be stopped by calling (.close node)
.
Throws IndexVersionOutOfSyncException if the index needs rebuilding.
NOTE: requires any dependencies on the classpath that the Crux modules may need. Accepts a map, or a JSON/EDN file or classpath resource. See https://opencrux.com/reference/configuration.html for details. Returns a node which implements ICruxAPI and java.io.Closeable. Latter allows the node to be stopped by calling `(.close node)`. Throws IndexVersionOutOfSyncException if the index needs rebuilding.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close