declareQueryable method

Queryable declareQueryable(
  1. Object keyExpr, {
  2. bool complete = false,
  3. Locality? allowedOrigin,
})

Declares a queryable on the given keyExpr.

Returns a Queryable whose Queryable.stream delivers Querys. Call Queryable.close when done to undeclare and release resources.

allowedOrigin restricts whose traffic this declaration accepts. Omitting it — or passing null — means canon decides, which is Locality.any. See Locality.

The complete parameter indicates whether this queryable is a complete source of data for its key expression (default: false).

⚠️ The returned Queryable.stream is UNBOUNDED, and pausing it does not stop the flow — and on this column the cost is native as well as Dart-side: every buffered query holds a z_owned_query_t clone open until it is disposed. Measured: a paused push queryable retained all 64 queries fired at it, against 9 for the bounded alternative at capacity: 8.

For a bounded consumer use declarePullQueryable and its PullQueryable.stream.

Throws ZenohException if the key expression is invalid. Throws StateError if the session has been closed.

Implementation

Queryable declareQueryable(
  Object keyExpr, {
  bool complete = false,
  Locality? allowedOrigin,
}) {
  return _withKeyExprArg(keyExpr, 'keyExpr', (loanedSession, loanedKe) {
    return Queryable.declare(
      loanedSession,
      loanedKe,
      keyExprString(keyExpr, 'keyExpr'),
      complete: complete,
      allowedOrigin: allowedOrigin,
    );
  });
}