iproto: override request handlers using event triggers (part 1)
This patch allows to override IPROTO request handlers by setting triggers
on the corresponding events before the initial `box.cfg{}' call.
For triggers that are set after the first `box.cfg{}', see next commit.
There are 2 types of iproto-overriding events:
1. set by request type id, e.g.:
- box.iproto.override[1]
- box.iproto.override[-1]
2. set by request type name (the name must be in the lowercase), e.g.:
- box.iproto.override.select
- box.iproto.override.unknown
Override-by-id allows to set a handler for a particular request type, that
is not known by the given version of Tarantool. This is not possible with
override-by-name, where a type name must be known by Tarantool. Also there
are a special type name "unknown" and a type id box.iproto.type.UNKNOWN
(== -1) that allow to set a single handler for all unknown request types.
Multiple triggers can be associated with a single event. The triggers are
called in reverse order of their installation, however triggers set by id
are called before triggers set by name.
If a trigger returns `false`, the next trigger in the list is called, or a
system handler if there are no more triggers. If a trigger returns `true`,
no more triggers or system handlers are called.
Part of #8138
NO_DOC=see next commit
NO_CHANGELOG=see next commit
Co-authored-by:
Andrey Saranchin <Andrey22102001@gmail.com>
Showing
- src/box/box.cc 2 additions, 0 deletionssrc/box/box.cc
- src/box/iproto.cc 284 additions, 20 deletionssrc/box/iproto.cc
- src/box/iproto_constants.c 2 additions, 0 deletionssrc/box/iproto_constants.c
- src/box/iproto_constants.h 33 additions, 0 deletionssrc/box/iproto_constants.h
- test/box-luatest/iproto_request_handlers_overriding_test.lua 202 additions, 8 deletionstest/box-luatest/iproto_request_handlers_overriding_test.lua
Loading
Please register or sign in to comment