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

Vladimir Davydov vdavydov at tarantool.org
Fri Jul 30 11:15:09 MSK 2021


On Fri, Jul 30, 2021 at 12:39:29AM +0200, Vladislav Shpilevoy wrote:
> 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.

If we stored a format in void *, we'd have to cast it on request
destruction to decrement its reference counter. To avoid that, we'd need
to introduce an abstract class for the decoder context, but since
currently the context can only be a tuple format, I don't think we
should bother now.

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

Let's change that in future, when we need it.


More information about the Tarantool-patches mailing list