General UDF question

Can UDF’s be used to call and external API or multiple API’s at once in an async way?

Thanks :slight_smile:

Unlikely. You can make calls to C functions

https://www.aerospike.com/docs/udf/developing_lua_modules.html#using-c-functions-in-udf-modules

But, there’s a limit on how long a UDF invocation runs

https://www.aerospike.com/docs/guide/record_udf.html#known-limitations

https://www.aerospike.com/docs/udf/known_limitations.html

You cannot do async operations inside the UDF.

Thanks for the clarification on this.

Well, looks like I’m back to the drawing board on that particular idea, I guess.

Cheers,

Not sure what you’re trying to do, but this isn’t typically what a user-defined function is for. Places where UDFs are appropriate include

  • To extend the functionality of atomic operators on data types
  • To do maintenance or rollup of data via a background UDF (a Lua function applied to multiple records using a scan or query)
  • To create aggregate functions using stream UDFs (that aren’t as latency sensitive as KV operations)

Seems that you need to do what you’re doing in the application. If you’re trying to identify a group of records take a look at predicate filters. You can get back just the keys, by setting the scan/query policy to not return the bins. You can then use an asynchronous process to get each record and make the API call on it.