基本的には、システムの非常に重要な部分で重要でないデータをBigQueryにストリーミングしたいと考えています。BigQueryに行をストリーミングするときにタイムアウトを指定するにはどうすればよいですか?
接続の問題がある場合、またはBigQueryが利用できない場合にプロセスを長時間ブロックしたくないため、最大タイムアウトを約2秒に指定したい場合があります(以前は起こっていましたが、それが頻繁に起こることを期待していない)。
私はBigQueryのに接続するためにgoogle/cloud
ライブラリを使用していて、基本的にはここで見つけたコード使用しています:私は自分のライブラリーは、HTTPクライアントとしてがつがつ食うを使用していますが、私は知らないと信じてhttps://cloud.google.com/bigquery/streaming-data-into-bigquery
use Google\Cloud\BigQuery\BigQueryClient;
/**
* Stream a row of data into your BigQuery table
* Example:
* ```
* $data = [
* "field1" => "value1",
* "field2" => "value2",
* ];
* stream_row($projectId, $datasetId, $tableId, $data);
* ```.
*
* @param string $projectId The Google project ID.
* @param string $datasetId The BigQuery dataset ID.
* @param string $tableId The BigQuery table ID.
* @param string $data An associative array representing a row of data.
* @param string $insertId An optional unique ID to guarantee data consistency.
*/
function stream_row($projectId, $datasetId, $tableId, $data, $insertId = null)
{
// instantiate the bigquery table service
$bigQuery = new BigQueryClient([
'projectId' => $projectId,
]);
$dataset = $bigQuery->dataset($datasetId);
$table = $dataset->table($tableId);
$insertResponse = $table->insertRows([
['insertId' => $insertId, 'data' => $data],
// additional rows can go here
]);
if ($insertResponse->isSuccessful()) {
print('Data streamed into BigQuery successfully' . PHP_EOL);
} else {
foreach ($insertResponse->failedRows() as $row) {
foreach ($row['errors'] as $error) {
printf('%s: %s' . PHP_EOL, $error['reason'], $error['message']);
}
}
}
}
をどのようにそれを渡すか、私はタイムアウトが設定された時間の後に発生したい。
そして次の世代のソリューション(適切なキューを使用して):https://shinesolutions.com/2014/12/19/license-to-queue/ –
私はこれが事実になるのではないかと心配しましたあなたのリンクの非常に便利ですが、そのためにありがとう! BigQueryに行を流すときにタイムアウトを指定するにはどうすればいいですか?この回答には、それが不可能であることが明示されていません。私はこのことについての規則を確信しています – Jeroen
私の質問の最も重要な部分は、「接続の問題があれば、プロセスを長時間ブロックしたくないからです」と述べるときです。それから、正解は「試みていない - ブロックしないことが重要であれば、代わりにこれをやる」ということです。 –