Get GRPC message
Gets the next message from the stream
- Parameters
- Advanced call ?
Function GetGRPCMessage(Val Connection, Val StreamID, Val DefaultFormat = "") Export
| Parameter | CLI option | Type | Required | Description |
|---|---|---|---|---|
| Connection | - | Arbitrary | ✔ | Connection object |
| StreamID | - | String | ✔ | Stream Identifier |
| DefaultFormat | - | String | ✖ | Expected data format if the server did not return output_format |
Returns
Map Of KeyAndValue - Processing result
This method has no additional advanced call parameters.
tip
DefaultFormat is necessary for streaming reception, as the server does not return format information after the first response
Caution
NOCLI: this method is not available in CLI version
1C:Enterprise/OneScript code example
URL = "http://localhost:9101";
Login = "bayselonarrend";
Password = "12we...";
Authorization = New Structure(Login, Password);
ConnectionSettings = OPI_ClickHouse.GetGRPCConnectionSettings(URL, Authorization);
Connection = OPI_ClickHouse.CreateGRPCConnection(ConnectionSettings);
Timeout = 10000;
OpeningResult = OPI_ClickHouse.OpenGRPCStream(Connection, Timeout);
If Not OpeningResult["result"] Then
Raise OpeningResult["error"];
Else
StreamID = OpeningResult["streamId"];
EndIf;
QueryText = "SELECT number FROM system.numbers LIMIT 1";
Request = OPI_ClickHouse.GetRequestSettings(QueryText, , , , "JSON");
Result = OPI_ClickHouse.SendGRPCMessage(Connection, StreamID, Request);
OPI_ClickHouse.CompleteGRPCSending(Connection, StreamID);
Data = "";
If Result["result"] Then
While True Do
Result = OPI_ClickHouse.GetGRPCMessage(Connection, StreamID, "JSON");
If Not Result["result"] Then
Break;
EndIf;
TextPart = Result["message"]["output"];
Data = Data + TextPart;
EndDo;
OPI_GRPC.CloseConnection(Connection);
Else
Raise Result["error"];
EndIf;
OPI_TypeConversion.GetCollection(Data);
Result
{
"meta": [
{
"name": "number",
"type": "UInt64"
}
],
"data": [
{
"number": "0"
}
],
"rows": 1,
"statistics": {
"elapsed": 0.000901684,
"rows_read": 0,
"bytes_read": 0
}
}