Last active
June 18, 2016 04:06
-
-
Save Jeweller-Tsai/dfa5b24db564d12623a03555b3d23cac 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
defmodule ElixirTail do | |
def tail path do | |
Stream.resource(fn -> File.open!(path) end, | |
fn file -> | |
case IO.read(file, :line) do | |
:eof -> | |
:timer.sleep 10 | |
{[], file} | |
data -> | |
IO.write data | |
{[data], file} | |
end | |
end, | |
fn file -> File.close(file) end) | |
|> Stream.run | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A rust version