MySQL Proxy Blueprints
Contents |
[edit] Rationale
MySQL Proxy uses Launchpad as its development platform.
Launchpad provides a feature/todo tracking feature called Blueprints but the content you can put in there is quite limited (it's not a Wiki). This page therefore provides a Wiki page for those blueprints that might need a little more space than just a few sentences.
[edit] Blueprints
[edit] The funnel plugin
Plugin was created by Nick Loeve.
This launchpad blueprint outlines a use case and implementation of a connection multiplexer plugin for mysql-proxy.
A multiplexer will allow a large number of front-end client connections to be 'funneled' into a smaller user-defined limit of back-end connections to the mysqld. For all incoming 'queries' a front-end connection will be assigned a back-end connection and then disconnected from that back-end once the query has completed. If a back-end connection is not available and the user-defined maximum of back-end connections has been reached, then the front-end connection will be placed into a backlog queue and the query will be handled once a back-end connection has become available and all prior pending items in the backlog have been cleared.
More to come once the feature set is more completely defined.
[edit] Use gperf to create faster lookup tables for Lua libs
A sample gperf input file could look like this:
%{
typedef enum commontoken_field {
COMMONTOKEN_NOTFOUND,
COMMONTOKEN_NAME,
COMMONTOKEN_TYPE,
COMMONTOKEN_TEXT,
COMMONTOKEN_LINE,
COMMONTOKEN_POSITION_IN_LINE,
COMMONTOKEN_INDEX
} commontoken_field_t;
commontoken_field_t commontoken_name_lookup(const char *str);
%}
struct commontoken_map { const char *name, commontoken_fields_t id }
%%
name, COMMONTOKEN_NAME
type, COMMONTOKEN_TYPE
text, COMMONTOKEN_TEXT
line, COMMONTOKEN_LINE
position_in_line, COMMONTOKEN_POSITION_IN_LINE
index, COMMONTOKEN_INDEX
%%
#ifdef __GNUC__
__inline
#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
__attribute__ ((__gnu_inline__))
#endif
#endif
const commontoken_field_t
commontoken_name_lookup(register const char *str, register unsigned int len) {
const struct commontoken_map *map = commontoken_name(str, len);
return map == NULL ? COMMONTOKEN_NOTFOUND : word->id;
}
Use this command line to generate the C code:
gperf -t -S 1 -G -C -N commontoken_name commontoken.gperf
In order to not be a nuisance, the gperf input file should be generated itself (oh joy, generate input to a code generator :)).
The gperf file is pretty regular if you look at it. All identifiers (struct, enum, typedef, function names) are closely related to each other. When generating the gperf input, all you should have to specify is a prefix (`COMMONTOKEN` in the above) and a list of strings ('name', 'text', etc.).
That would be enough to generate the above file. Then you simply hook it up in the Makefile (or maybe even a bootstrap script so we don't have to require gperf to be installed when building from source) and include the generated file.