MEDIUM: stick-table: make it easier to register extra data types
authorWilly Tarreau <w@1wt.eu>
Tue, 15 Jul 2014 14:44:27 +0000 (16:44 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 15 Jul 2014 17:14:52 +0000 (19:14 +0200)
commitedee1d60b7868d61e6bfc18ea82d4480113501b0
tree2bb8e6d29e4b65b82ec099caa7479e7998c57839
parente12704bfc7c4192385dc8c5d600020439c0319df
MEDIUM: stick-table: make it easier to register extra data types

Some users want to add their own data types to stick tables. We don't
want to use a linked list here for performance reasons, so we need to
continue to use an indexed array. This patch allows one to reserve a
compile-time-defined number of extra data types by setting the new
macro STKTABLE_EXTRA_DATA_TYPES to anything greater than zero, keeping
in mind that anything larger will slightly inflate the memory consumed
by stick tables (not per entry though).

Then calling stktable_register_data_store() with the new keyword will
either register a new keyword or fail if the desired entry was already
taken or the keyword already registered.

Note that this patch does not dictate how the data will be used, it only
offers the possibility to create new keywords and have an index to
reference them in the config and in the tables. The caller will not be
able to use stktable_data_cast() and will have to explicitly cast the
stable pointers to the expected types. It can be used for experimentation
as well.
include/common/defaults.h
include/proto/stick_table.h
include/types/stick_table.h
src/stick_table.c