[Tarantool-patches] [PATCH] net.box: add __serialize and __tostring methods for future objects

Vladimir Davydov vdavydov at tarantool.org
Tue Aug 17 10:58:56 MSK 2021


On Fri, Aug 13, 2021 at 08:41:28PM +0300, Yaroslav Dynnikov wrote:
> On Fri, 13 Aug 2021 at 15:58, Vladimir Davydov <vdavydov at tarantool.org>
> wrote:
> 
> > Example output (for more examples see the test output):
> >
> >   tarantool> f = c:eval('return 123', {}, {is_async = true})
> >   ---
> >   ...
> >
> >   tarantool> tostring(f)
> >   ---
> >   - 'net.box.request: 7'
> >   ...
> >
> 
> I think sync has no sense here. It's useless without other info (peer,
> function).
> Also, it complicates the tests and makes them less reliable.
> IMHO simple 'net.box.request' is enough.

Agree.

> 
> 
> >   tarantool> f
> >   ---
> >   - method: eval
> >     on_push_ctx: []
> >     result: [123]
> >     on_push: 'function: builtin#91'
> >     sync: 7
> >   ...
> >
> 
> This is also weird:
> 
> tarantool> f
> ---
> - on_push_ctx: []
>   method: call
>   sync: 4
>   on_push: 'function: builtin#91'
> ...
> 
> tarantool> f.sync
> ---
> - null
> ...
> 
> tarantool> f.method
> ---
> - null
> ...
> 
> Why displaying inaccessible fields? You leave a developer no choice:
> 
> tarantool> debug.getmetatable(f).__serialize(f).method
> ---
> - call
> ...
> 
> Of course, I miss that fields, but please, there should be another way to
> access them.
> 
> Also, speaking of
> https://github.com/tarantool/tarantool/commit/b996502b403c1698c4b0886de636faa0a63cfb70
> ,
> which of them are you going to merge first? Whichever it is, I guess the
> second one is destined to be refactored afterward.

Reworked the patch. Now __serialize returns user-defined fields if there
are any. If there's no fields, it falls back on __tostring. Will send v2
in reply to this email. Please take a look.


More information about the Tarantool-patches mailing list