-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
254 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from indykite_sdk.indykite.ingest.v1beta2 import ingest_api_pb2 as pb2 | ||
from indykite_sdk.model.ingest_record import StreamRecordsResponse, IngestRecordResponse | ||
import sys | ||
import indykite_sdk.utils.logger as logger | ||
|
||
|
||
def generate_records_request(self, records): | ||
""" | ||
Create iterator for record requests | ||
:param self: | ||
:param records: list of records | ||
:return: yield record_request | ||
""" | ||
"""Create iterator for record requests.""" | ||
for record in records: | ||
record_request = pb2.StreamRecordsRequest(record=record) | ||
yield record_request | ||
|
||
|
||
def stream_records(self, records): | ||
""" | ||
send records in stream | ||
:param self: | ||
:param records: list of records | ||
:return: list of deserialized StreamRecordsResponses | ||
""" | ||
sys.excepthook = logger.handle_excepthook | ||
try: | ||
record_iterator = self.generate_records_request(records) | ||
response_iterator = self.stub.StreamRecords(record_iterator) | ||
responses = list(response_iterator) | ||
res = [StreamRecordsResponse.deserialize(response) for response in responses] | ||
return res | ||
|
||
except Exception as exception: | ||
return logger.logger_error(exception) | ||
|
||
|