Fs2: [fs2.io.file] Functionality to `tail -f` a file, i. e. keep reading it while it's being written to

Created on 10 Jun 2019  路  3Comments  路  Source: typelevel/fs2

While working on a log analysis app, I noticed that there are no methods in fs2.io.file that allow reading a file that at the same time as it is being written. What I needed was essentially to stream a file as in Linux's tail -f.

file.readAll as well as file.readRange finish the stream as soon as they reaches EOF.

I tweaked the methods pulls._readAllFromFileHandle0 and pulls.readAllFromFileHandle to allow for a file.keepReading that does the job. I can make a pull request if the feature can be useful to others.

Most helpful comment

That sounds really useful! PR welcome.

All 3 comments

That sounds really useful! PR welcome.

I did that: PR #1506.

For testing, as I commented there, I used Scala's own Future and Java's Thread.sleep to write asynchronously to the file that is being read. Doesn't seem the best way to do it...

Fixed by #1506

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kubukoz picture kubukoz  路  5Comments

mpilquist picture mpilquist  路  12Comments

gvolpe picture gvolpe  路  9Comments

zainab-ali picture zainab-ali  路  15Comments

LukaJCB picture LukaJCB  路  6Comments