Example run

Run a procedure in ThingsDB. A successful run request will respond with a DATA (18) package.


[scope, procedure, ...args]

The args are parsed (and must match) to the procedure.

The socket needs to be authorized before sending a run request. See the auth example for how to authorize a socket connection.


As an example we assume there is a procedure created in the @thingsdb scope, called “add_one” which just adds one to a given value. The procedure can be created using new_procedure('add_one', |x| x + 1);, see new_procedure().

This is the data we want to pack:

["@t", "add_one", 41]

Serializing the above using MessagePack results in the following 13 bytes:


Now we create the header. For this example we just use ID 0:

  • Data length (13) \x0d\x00\x00\x00
  • Identifier (0) \x00\x00
  • Run package type (37) \x25
  • Inverse type check bit (218) \xda

Sending the Query package


Responding Data package


We see that the DATA response package has a header with attached data of length 1.

Unpacking the data * using MessagePack will return the expected value 42 which is the expected result.