sanchezzzhak / kak-clickhouse

Yii2 ext. ClickHouse
69 stars 43 forks source link

How to add timeout option? #45

Closed Draconic closed 4 years ago

Draconic commented 4 years ago

Currently yii\httpclient\CurlTransport is used in order to make a request. Unfortunately I was unable to find a way to pass CURLOPT_TIMEOUT to the transport and/or 'timeout' option to the Request. Is there such a way?

If no, I may try to work upon a solution for global client/transport config in class configuration options.

sanchezzzhak commented 4 years ago

Hi. Yes, there is such a possibility

    'requestConfig' => [
        'class' => 'kak\clickhouse\httpclient\Request',
        'options' => [
          'timeout' => 60
        ]
    ]

other allow options https://www.yiiframework.com/extension/yiisoft/yii2-httpclient/doc/guide/2.0/en/usage-request-options

Full example config

return [ 
  'class' => 'kak\clickhouse\Connection',
   'dsn' => 'localhost',
   'database' => 'default',
   'port' => 8123,
   'username' => '{username}',
   'password' => '{password}',
   'enableSchemaCache' => true,
   'schemaCache' => 'cache',
   'schemaCacheDuration' => 86400,
    'options' => [
       'log_queries' => 1,                           // profile query view table system.log_queries
       'max_query_size' => 100000000    
    ],
    'requestConfig' => [
        'class' => 'kak\clickhouse\httpclient\Request',
        'options' => [
          'timeout' => 60
        ]
    ]

];
Draconic commented 4 years ago

Thank you very much! I believe the issue is closed then.