[Tarantool-patches] [PATCH 06/20] net.box: rename request.ctx to request.format

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Fri Jul 30 01:39:29 MSK 2021


On 29.07.2021 12:54, Vladimir Davydov wrote:
> On Thu, Jul 29, 2021 at 12:49:39AM +0200, Vladislav Shpilevoy wrote:
>> On 23.07.2021 13:07, Vladimir Davydov via Tarantool-patches wrote:
>>> Request context only stores tuple format or nil, which is used for
>>> decoding a response. Rename it appropriately.
>>
>> The name ctx was chosen intentionally, because when you pass it to
>> method_decoder[request.method](...), you don't know how will it be
>> used and what is stores. It was internal for the request sender and
>> codec. Why do you need to change it?
> 
> For one thing, it's always either nil or format. Naming it ctx is
> confusing.
> 
> The reason I'm doing this in the scope of this series is that it is
> stored in the request class. Lua isn't a strictly typed language so we
> can store whatever we want there, but in C we need to know the type to
> define the request struct, see netbox_request::format here:
> 
> https://github.com/tarantool/tarantool/blob/73cab8402f7e098c8e908af9a2b72695c754c472/src/box/lua/net_box.c#L99
> 
> Turning ctx to format solves this problem.
You could store it as `void *` then. It just looks ugly, for
instance, when you pass `struct tuple_format` into netbox_decode_nil().
Not all responses consist of tuples or even have a body.

Up to you. We could change it in the future if need.


More information about the Tarantool-patches mailing list