Skip to content

Commit 99484e8

Browse files
author
igor
committed
Migrate setTimeout from Float to Int
1 parent c8fa3e3 commit 99484e8

File tree

5 files changed

+18
-11
lines changed

5 files changed

+18
-11
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ $config = [
6363
];
6464
$db = new ClickHouseDB\Client($config);
6565
$db->database('default');
66-
$db->setTimeout(1.5); // 1500 ms
66+
$db->setTimeout(1.5); // 1 second , support only Int value
6767
$db->setTimeout(10); // 10 seconds
6868
$db->setConnectTimeOut(5); // 5 seconds
6969
$db->ping(true); // if can`t connect throw exception
@@ -788,7 +788,7 @@ $cli->ping();
788788
$result=$cl->truncateTable('dbNane.TableName_sharded');
789789

790790
// get one active node ( random )
791-
$cl->activeClient()->setTimeout(0.01);
791+
$cl->activeClient()->setTimeout(500);
792792
$cl->activeClient()->write("DROP TABLE IF EXISTS default.asdasdasd ON CLUSTER cluster2");
793793

794794

src/Client.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public function setHost($host)
183183
/**
184184
* @return Settings
185185
*/
186-
public function setTimeout(float $timeout)
186+
public function setTimeout(int $timeout)
187187
{
188188
return $this->settings()->max_execution_time($timeout);
189189
}

src/Settings.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,12 @@ public function makeSessionId()
172172
}
173173

174174
/**
175-
* @param int|float $time
175+
* @param int $time
176176
* @return $this
177177
*/
178178
public function max_execution_time($time)
179179
{
180-
$this->set('max_execution_time', $time);
180+
$this->set('max_execution_time', intval($time));
181181
return $this;
182182
}
183183

tests/ClientTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -918,13 +918,13 @@ public function testInsertTableTimeout()
918918
$this->create_table_summing_url_views();
919919

920920

921-
$this->client->setTimeout(0.01);
921+
$this->client->settings()->set('max_execution_time',0.1);
922922

923923

924924
$stat = $this->client->insertBatchFiles('summing_url_views', $file_data_names, [
925925
'event_time', 'url_hash', 'site_id', 'views', 'v_00', 'v_55'
926926
]);
927-
$this->client->ping();
927+
928928
}
929929
/**
930930
*

tests/FormatQueryTest.php

+11-4
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,23 @@ public function testClientTimeoutSettings()
5858
{
5959
$this->client->database('default');
6060

61-
$timeout = 1.5;
61+
$timeout = 0.55;
6262
$this->client->setTimeout($timeout); // 1500 ms
63-
$this->assertSame($timeout, $this->client->getTimeout());
63+
$this->client->select('SELECT 123,123 as ping ')->rows();
64+
$this->assertSame(intval($timeout), $this->client->getTimeout());
6465

6566
$timeout = 10.0;
6667
$this->client->setTimeout($timeout); // 10 seconds
67-
$this->assertSame($timeout, $this->client->getTimeout());
68+
$this->client->select('SELECT 123,123 as ping ')->rows();
69+
$this->assertSame(intval($timeout), $this->client->getTimeout());
6870

69-
$timeout = 5.0;
71+
$timeout = 5.14;
7072
$this->client->setConnectTimeOut($timeout); // 5 seconds
73+
$this->client->select('SELECT 123,123 as ping ')->rows();
7174
$this->assertSame(5, $this->client->getConnectTimeOut());
7275
}
76+
77+
78+
79+
7380
}

0 commit comments

Comments
 (0)