MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / put_function

Method put_function

nodedb/src/control/security/catalog/functions.rs:13–30  ·  view source on GitHub ↗

Store a user-defined function record. Key format: `"{tenant_id}:{function_name}"`. Overwrites any existing definition with the same key (for CREATE OR REPLACE).

(&self, func: &StoredFunction)

Source from the content-addressed store, hash-verified

11 /// Key format: `"{tenant_id}:{function_name}"`.
12 /// Overwrites any existing definition with the same key (for CREATE OR REPLACE).
13 pub fn put_function(&self, func: &StoredFunction) -> crate::Result<()> {
14 let key = function_key(func.tenant_id, &func.name);
15 let bytes =
16 zerompk::to_msgpack_vec(func).map_err(|e| catalog_err("serialize function", e))?;
17 let write_txn = self
18 .db
19 .begin_write()
20 .map_err(|e| catalog_err("write txn", e))?;
21 {
22 let mut table = write_txn
23 .open_table(FUNCTIONS)
24 .map_err(|e| catalog_err("open functions", e))?;
25 table
26 .insert(key.as_str(), bytes.as_slice())
27 .map_err(|e| catalog_err("insert function", e))?;
28 }
29 write_txn.commit().map_err(|e| catalog_err("commit", e))
30 }
31
32 /// Get a single function by tenant_id + name.
33 pub fn get_function(

Callers 10

put_and_getFunction · 0.80
delete_functionFunction · 0.80
load_for_tenant_filtersFunction · 0.80
replace_overwritesFunction · 0.80
putFunction · 0.80
create_wasm_functionFunction · 0.80
create_wasm_aggregateFunction · 0.80
upload_wasmFunction · 0.80

Calls 7

function_keyFunction · 0.85
begin_writeMethod · 0.80
catalog_errFunction · 0.70
insertMethod · 0.45
as_strMethod · 0.45
as_sliceMethod · 0.45
commitMethod · 0.45

Tested by 6

put_and_getFunction · 0.64
delete_functionFunction · 0.64
load_for_tenant_filtersFunction · 0.64
replace_overwritesFunction · 0.64