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

Add SyncOpen config option #48

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ravenblackx
Copy link

@ravenblackx ravenblackx commented Jun 2, 2022

This new option allows the client to avoid the following race condition:

  1. open file "example.txt"
  2. StartTail("example.txt", Location: &SeekInfo(0, io.SeekEnd))
  3. append "hello\n" to example.txt

Without SyncOpen, this sequence may or may not see the line "hello" depending on a race between the goroutine that writes it and the goroutine that Tail runs.

With SyncOpen, the StartTail function doesn't return until the requested seek operation has been performed (unless the file doesn't exist, in which case no seek operation is performed, ensuring position 0 will be used when the file is created), so any writes performed after StartTail are guaranteed to be seen by the tail operation.

Addresses issue #49

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.

1 participant