> On Feb 27, 2020, at 10:13 AM, Leif Hedstrom <zw...@apache.org> wrote:
>
> Hi all,
>
> This is an idea from Bryan Call, which he suggested as a solution for
> reloadable plugins changes that are now in 9.0.x. I recently ran into a
> different use case (thanks Miles …), which could really benefit (performance
> wise) with such APIs. I *could* use the TxnArg APIs instead, but these new
> global arg APIs would make it noticeable faster (and less locking). So, I’m
> writing up this proposal based on these ideas, for discussion / adjustments.
After discussions here, and with help from Alan and Bryan, I’ve made some
significant changes to these APIs now. Here’s the new design:
1) All old APIs are marked deprecated!
2) 5 new APIs are introduced
3) The Global (GLB) type of user args is added.
Item #2 now makes the API look like this:
tsapi TSReturnCode TSUserArgIndexReserve(TSUserArgType type, const char *name,
const char *description, int *arg_idx);
tsapi TSReturnCode TSUserArgIndexNameLookup(TSUserArgType type, const char
*name, int *arg_idx, const char **description);
tsapi TSReturnCode TSUserArgIndexLookup(TSUserArgType type, int arg_idx, const
char **name, const char **description);
tsapi void TSUserArgSet(void *data, int arg_idx, void *arg);
tsapi void *TSUserArgGet(void *data, int arg_idx);
The first three now takes a TSUserArgType argument:
typedef enum {
TS_USER_ARGS_TXN, ///< Transaction based.
TS_USER_ARGS_SSN, ///< Session based
TS_USER_ARGS_VCONN, ///< VConnection based
TS_USER_ARGS_GLB, ///< Global based
TS_USER_ARGS_COUNT ///< Fake enum, # of valid entries.
} TSUserArgType;
The Get()/Set() are then context sensitive. You pass in a “txnp”, it uses the
TXN slots, you pass in a “ssnp”, it uses the SSN slot. For the “GLB” slots,
simply pass in a nullptr (since the global doesn’t have a context).
Thoughts? One question is if we should change the “int” type on the index to
e.g. “size_t”. That’s slightly unorthodox for our existing APIs, where we
frivolously use “int” for such things (so size_t would be somewhat unorthodox
in ts/ts.h).
— Leif