-
Notifications
You must be signed in to change notification settings - Fork 378
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
feat: Handle stdin
closure and shut down the tailer.
#868
Merged
Conversation
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
Save some work by only tailing it once at startup; if we glob it, then we have to check every time and we then end up having to also do the work in the logstream of handling the "already closed".
The work of globbing a single pattern is separate from iterating over all patterns, setting us up to start a goroutine per pattern instead of an iterator. Issue: #331
We would like to use this in per-pattern goroutines. Issue: #331
Instead of collecting sockets and tailing them after, just tail them straight away. This makes the "early exit" check for "no things" broken, so replace that with a check in the final shutdown handler that there were no active globs. This will be replaced in the next few changes once migrated to goroutines and we can use only the `WaitGroup` for counting globs, too, but in the meantime this is more correct than the previous code. Issue: #331
Restructure the testserver constructor.
We get greater control of what's being polled for by doing so. This also removes noise so in a few changes time I can clean up the log pattern poller.
…eams. This gives us greater control in test.
This has no effect on test behaviour.
…tter. We now can explicitly control these two events, making the tests faster. Update the test tail comment explaining what the waker count parameters do; I keep forgetting, this hint helps!
This lets us await a goroutine per pattern, and if there are none, no waiting need be done, making shutdown cleaner. The completion poller is still a bit of a mess though.
This is not a routine we wait for completion of to shut down the tailer, it's shut down when the tailer is exiting. Move the stdin check to logstream so it can use it too.
Rename the waker option and the goroutine launcher as it's not just for stale logs anymore. Fix tests that were relying on the pattern poller for log completion.
Unit Test Results 1 files 27 suites 8m 50s ⏱️ Results for commit e99f7e5. ♻️ This comment has been updated with latest results. |
github-merge-queue
bot
removed this pull request from the merge queue due to failed status checks
May 26, 2024
We pass the context to the functions so we don't need to keep it in here.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With this change the tailer does a better job of tracking current and future work, shutting down when all streams are completed. If there are no filesystem patterns to watch and all streams close, (e.g. stdin closes) then
mtail
will also stop.This fixes a longstanding issue where
mtail
would remain running ifstdin
was the only log, and was closed.Fixes: #331