Open GRPC stream
Initializes the I/O stream for communication
- Parameters
- Advanced call ?
Function OpenGRPCStream(Val Connection, Val Timeout = 10000) Export
| Parameter | CLI option | Type | Required | Description |
|---|---|---|---|---|
| Connection | - | Arbitrary | ✔ | GRPC connection object |
| Timeout | - | Number | ✖ | Timeout (in ms) |
Returns
Map Of KeyAndValue - Processing result
This method has no additional advanced call parameters.
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);
Result = OPI_ClickHouse.OpenGRPCStream(Connection); // <---
If Not Result["result"] Then
Raise Result["error"];
Else
StreamID = Result["streamId"];
EndIf;
QueryText = "INSERT INTO events_stream_test FORMAT JSONEachRow";
DataFormat = "JSON";
CurrentDate = Date("20260101100000");
Counter = 0;
While Counter < 5 Do
Record = New Structure;
Record.Insert("id" , Counter + 1);
Record.Insert("timestamp" , CurrentDate);
Record.Insert("user_id" , 100 + Counter);
Record.Insert("event_type" , "stream_test");
Record.Insert("payload" , "{}");
Record = OPI_Tools.JSONString(Record) + Chars.LF;
Last = Counter = 4;
If Counter = 0 Then
Request = OPI_ClickHouse.GetRequestSettings(QueryText, "default", , Record, DataFormat);
CurrentSend = OPI_ClickHouse.SendGRPCMessage(Connection, StreamID, Request, , Not Last);
Else
CurrentSend = OPI_ClickHouse.SendGRPCData(Connection, StreamID, Record, Not Last);
EndIf;
If Not CurrentSend["result"] Then
Error = CurrentSend["error"];
If Error <> "Timeout" Then
Raise OPI_Tools.JSONString(CurrentSend);
EndIf;
EndIf;
Counter = Counter + 1;
EndDo;
Completion = OPI_ClickHouse.CompleteGRPCSending(Connection, StreamID);
FinalMessage = OPI_ClickHouse.GetGRPCMessage(Connection, StreamID);
OPI_GRPC.CloseConnection(Connection);
Result
{
"result": true,
"streamId": "9235b8f8-8a7e-404f-8c64-6e87224bc170"
}