-
-
Notifications
You must be signed in to change notification settings - Fork 393
Open
Description
I'm looking for a way to combine WritableStream with async await. I saw some old issues in this repository related to this problem and didn't find any relevant solution.
What am I trying to do:
- Get file stream from S3
- Parse file with streams using htmlparser2
- During parsing, insert chunks of data to Kafka
Example of code is following:
const readable = getFileStreamFromS3()
let buffer = []
const parser = new WStream(
{
onopentag(name, attributes) {
// ... collect data on open tag
},
ontext(text) {
// collect text on text
},
async onclosetag(tagname) {
buffer.push(data)
if (buffer.length >= 100) {
await pushToKafka(buffer)
buffer = []
}
},
},
{ xmlMode: true },
)
return new Promise(resolve => readable.pipe(writableStream).on('finish', resolve))
However, it doesn't seem to work. Any ideas on how to implement this feature?
Metadata
Metadata
Assignees
Labels
No labels