Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedSabthar committed Aug 7, 2024
1 parent c58b4f1 commit bb64601
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions ballerina/event_stream_writer.bal
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,28 @@ class EventStreamWriter {
self.eventStream = eventStream;
}

isolated function writeEventStream() returns error? {
var iterator = self.eventStream.iterator();
isolated function writeEventStream() {
do {
while true {
record {byte[] value;}? event = check iterator.next();
record {byte[] value;}? event = check self.eventStream.next();
if event is () {
self.closeEventStream();
return;
}
check trap self.writeEventStreamBytesToOutputStream(event.value);
check externWriteEventStreamBytesToOutputStream(self, event.value);
}
} on fail error err {
log:printError("unable to write event stream to wire", err);
error? result = self.eventStream.close();
if result is error {
log:printError("unable to close the stream", err);
}
self.closeEventStream();
return;
}
}

isolated function writeEventStreamBytesToOutputStream(byte[] eventBytes) returns error? {
return externWriteEventStreamBytesToOutputStream(self, eventBytes);
isolated function closeEventStream() {
error? result = self.eventStream.close();
if result is error {
log:printError("unable to close the stream", result);
}
}
}

Expand Down

0 comments on commit bb64601

Please sign in to comment.