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

Consider moving tarantool.* ini settings to the instance level #75

Open
rybakit opened this issue Mar 16, 2016 · 4 comments
Open

Consider moving tarantool.* ini settings to the instance level #75

rybakit opened this issue Mar 16, 2016 · 4 comments
Assignees
Labels
feature A new functionality
Milestone

Comments

@rybakit
Copy link
Collaborator

rybakit commented Mar 16, 2016

Is there a reason to put settings like timeout, persistence, etc in php.ini? Usually, such kind of settings are made to be configurable on an instance level, instead of globally. See some examples:

http://php.net/manual/en/mongodb-driver-manager.construct.php
https://github.com/phpredis/phpredis#example-1
http://php.net/manual/en/function.pg-connect.php

So, currently you can't have two Tarantool instances with different timeout settings, or one with a persistent connection while the other with a regular one. Also, putting those settings in php.ini decreases scripts portability, as the same script can behave differently depending on php.ini settings.

@bigbes
Copy link
Contributor

bigbes commented Mar 16, 2016

You have ability to modify this settings using ini_set, so it's no difference

@bigbes bigbes added the question Further information is requested label Mar 16, 2016
@bigbes bigbes self-assigned this Mar 16, 2016
@bigbes bigbes closed this as completed Mar 16, 2016
@rybakit
Copy link
Collaborator Author

rybakit commented Mar 16, 2016

@bigbes Do you propose to overwrite a global setting every time one need a custom one? Something like this? :

ini_set('tarantool.timeout', 5);
$t1 = new Tarantool();
ini_set('tarantool.timeout', 15);
$t2 = new Tarantool();

ini_set('tarantool.request_timeout', 5);
$t1->ping();
$t1->call(...);

ini_set('tarantool.request_timeout', 15);
$t2->ping();
$t2->call(...);

Or create a wrapper to modify and restore settings after a call:

function call_with_custom_timeout($tarantool, $args, $timeout)
{
    $originalTimeout = ini_get('tarantool.request_timeout');
    ini_set('tarantool.request_timeout', $timeout);

    $tarantool->call($args);
   ini_set('tarantool.request_timeout', $originalTimeout);
}

$t1 = new Tarantool();
$t2 = new Tarantool();

call_with_custom_timeout($t1, 'foo', 5);
call_with_custom_timeout($t2, 'bar', 15);

Both these options don't look right to me.

@bigbes
Copy link
Contributor

bigbes commented Mar 25, 2016

Discussed. When new API would be presented - it would be OK to implement this

@bigbes bigbes reopened this Mar 25, 2016
@bigbes bigbes added this to the 0.1.0 milestone Mar 25, 2016
@bigbes bigbes added feature A new functionality and removed question Further information is requested labels Jun 22, 2016
@bigbes bigbes assigned bigbes and unassigned bigbes Jun 23, 2016
@Totktonada Totktonada modified the milestones: 0.1.0, wishlist Mar 23, 2020
@Totktonada
Copy link
Member

NB: Don't forget to add call_16 option to choose default call() behaviour. See PR #167 for the related discussion.

I like the idea suggested by @rybakit about using a separate static method (like Client::fromOptions()) to construct a client from an associative array of options. The discussion is in PR #167.

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

No branches or pull requests

3 participants