deleteResource method
Deletes a resource on the given keyExpr.
An optional timestamp can be attached to the message; borrowed, not
consumed.
Send options
congestionControl, priority, isExpress and allowedDestination are
each optional, and omitting one — or passing null — means the same
thing: canon decides. This binding substitutes no value of its own.
On this path canon's defaults are CongestionControl.drop (a push
operation; get and declareQuerier default to CongestionControl.block
instead), Priority.data, isExpress: false, and Locality.any.
⚠️ Read CongestionControl before selecting CongestionControl.block: it can park the calling thread for seconds and then close the transport.
Throws ZenohException if the key expression is invalid or the delete fails. Throws StateError if the session has been closed.
⛔ Throws ArgumentError if congestionControl is
CongestionControl.blockFirst and the loaded native was built without
Z_FEATURE_UNSTABLE_API. canon declares
Z_CONGESTION_CONTROL_BLOCK_FIRST only under that flag, so on such a
build there is no value to send. Pass CongestionControl.block or
CongestionControl.drop, or select the unstable native through your
app's user_defines.
Implementation
void deleteResource(
Object keyExpr, {
Timestamp? timestamp,
CongestionControl? congestionControl,
Priority? priority,
bool? isExpress,
Locality? allowedDestination,
}) {
// FIRST STATEMENT: ahead of the timestamp allocation and the key
// expression's validation.
requireCongestionControlSupported(congestionControl);
final tsPtr = timestamp != null ? _timestampToNative(timestamp) : nullptr;
try {
_withKeyExprArg<void>(keyExpr, 'keyExpr', (loanedSession, loanedKe) {
final rc = bindings.zd_delete(
loanedSession.cast(),
loanedKe.cast(),
tsPtr.cast(),
congestionControl?.value ?? -1,
priority?.value ?? -1,
isExpress == null ? -1 : (isExpress ? 1 : 0),
allowedDestination?.value ?? -1,
);
if (rc != 0) {
throw ZenohException('Delete failed', rc);
}
});
} finally {
if (tsPtr != nullptr) calloc.free(tsPtr);
}
}