Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow asynchronous codecs #14

Closed
wants to merge 1 commit into from

Conversation

christianbundy
Copy link
Member

This resolves #13 by wrapping codecs in Promise.resolve or Promise.all for batch operations, and adds an async test which is just the flumelog.js test with setTimeout. This shouldn't have any effect on synchronous codecs.

I don't think we're currently handling codec errors, so I've left reject() unused, but if there's an elegant way to handle promise rejections I'd be happy to implement it.

@dominictarr
Copy link
Collaborator

reflecting on this a while... async codecs don't make sense: a codec is just a decoding format. that we are doing decrypting inside the codec in secure-scuttlebutt is an ugly hack that only works because decrypting is sync. I don't want to expand that hack by making codecs officially async.

However, we could add an async map step in flumedb... it would wrap the log, affecting the output of log.stream and log.get via an async function... then it would work with any sort of flumelog, not just flumelog-offset (note: I am working on http://github.com/dominictarr/flumelog-random-access-file which has a different format and is much faster than flumelog-offset)

@christianbundy
Copy link
Member Author

Thanks! I'm not familiar with flumedb, but I'll look around and see if I can get another prototype working. Thanks again for taking a look at this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Async codecs
2 participants