Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add call_semantics option to select call command code #9

Merged
merged 5 commits into from
Nov 11, 2019

Conversation

DarkWiiPlayer
Copy link
Contributor

@DarkWiiPlayer DarkWiiPlayer commented Oct 13, 2019

The old (0x06) returns a table with the return values of the function
call, where each value is wrapped in an array. The new command returns a
table that contains the values unwrapped.

This saves table allocations, thus creating less unnecessary work for
the garbage collector.

see also: #8

The old (0x06) returns a table with the return values of the function
call, where each value is wrapped in an array. The new command returns a
table that contains the values unwrapped.

This saves table allocations, thus creating less unnecessary work for
the garbage collector.
@DarkWiiPlayer
Copy link
Contributor Author

DarkWiiPlayer commented Oct 13, 2019

On the technical side it's all implemented; however, I'm not at all happy with the new methods name ncall (new call); it seems pretty dumb, since it most likely doesn't matter to a user which one is "new".

Another name I considered was call_nowrap, but that also doesn't really explain itself well unless you know what call does, so it's also confusing if you don't care about the protocol and just want your tarantool-integration to work.

Another option would be to add an option to the creation of the object, something like

db = tarantool:new {
   user = 'foo'
   -- ...
   wrap_call_results = false;
}

where wrap_call_results defaults to true, with a big disclaimer that it will at some point be changed to false and people should fix their code.

Either way, my opinion is that this should be the default behavior for call; it's just more intuitive and better for performance, so I think the goal should be to some some day™ switch them out.

@DarkWiiPlayer
Copy link
Contributor Author

I just changed it so now there's only call, but also added a new configuration value to the tarantool:new method: call_semantics, which defaults to 'old'. (values can be 'old' or 'new', everything else errors)

I propose adding it to the readme example with a warning that the default will change in the future, and it should be set manually to 'old' in projects that need the old call result.

@DarkWiiPlayer DarkWiiPlayer changed the title Add ncall method for new (0x0a) call command Add call_semantics option to select call command code Oct 16, 2019
@DarkWiiPlayer DarkWiiPlayer marked this pull request as ready for review November 7, 2019 17:02
@DarkWiiPlayer
Copy link
Contributor Author

I think this is the least annoying way of implementing it and it seems to work pretty well for me. Some additional testing would of course be a good idea, but for me it seemed to work without bugs.

@DarkWiiPlayer
Copy link
Contributor Author

Also, for now I added a warning that the default value of "old" may change at some point; if you already know whether you actually want to change that, you could change it to will (or just leave it the way it is)

@perusio perusio merged commit 7eb1415 into perusio:origin Nov 11, 2019
@perusio
Copy link
Owner

perusio commented Nov 11, 2019

I will merge it and test it myself this week. Danke.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants