-
-
Save 3b/83fb8e20b14413b320c8213f04fb261f to your computer and use it in GitHub Desktop.
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
(defun parse-logs (stream) | |
(let ((channel (lparallel:make-channel)) | |
(count 0) | |
(bad 0)) | |
(loop for line = (read-line stream nil nil) | |
while line | |
when (json-line-p line) | |
do (incf count) | |
(lparallel:submit-task | |
channel | |
(let ((line line)) | |
(lambda () | |
(multiple-value-list (ignore-errors (parse-line line))))))) | |
(loop repeat count | |
for (result error) = (lparallel:receive-result channel) | |
if error | |
do (incf bad) | |
else if (slowlog-p result) | |
collect result into slowlogs | |
else if (grok-fail-p result) | |
collect result into groklogs | |
finally (return (values slowlogs groklogs bad))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment