Persistent edge queries
In previous chapters you learned how to run regular edge queries with Store-and-Forward (SNF). This chapter describes how to create persistent edge queries that run autonomously.
Persistent edge queries are defined using the OSQL type
EdgeQuery
. All instances of type EdgeQuery
are always started when an
edge listener is started.
The type EdgeQuery
has the propeties:
create type EdgeQuery;
create function name(EdgeQuery eq) -> Charstring key as stored;
create function statement(EdgeQuery eq) -> Charstring as stored;
create function options(EdgeQuery eq) -> Record as stored;
As the function names name
, statement
, and options
suggest, the
properties of EdgeQuery
are very similar to the arguments of
edge_cq
. The main difference is that the property name
is
essentially the id of the query when it runs autonomously on the edge.
When an edge starts it will go through all instances of EdgeQuery
and start them. If you dynamically create more EdgeQuery
objects
during an interactive session they will be used at the next edge
restart. You can activate a persistent edge query eq
by calling
run_stored_edge_query(eq)
.
Documentation of properties of the type Edgequery
:
select doc(f)
from Function f
where f in methods(typenamed("Edgequery"))
To run this code block you must be logged in and your studio instance must be started.
You can cancel a persistent edge query as usual with
cancel_edge_cq()
. However if you do not want the query to run again
on the next restart of the edge you will have to update and save the
local database to remove the instance of EdgeQuery
.