You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to be able to tell when the file is reopened. However having to deal with an event (channel, error code, ...) in case of reopen feels like a kludge. What about simply adding a byte position of the start of each line in the Line structure. There is already the timestamp. This way users can detect when the file was reopened because the position is no longer monotonically increasing.
What do you think?
The text was updated successfully, but these errors were encountered:
If the original intent is to detect a reopen event, then the issue title should say so, should it not? Adding line position is only a workaround to achieve this goal (and the user code would still have keep track of the monotonically increasing pattern). Taking a step back and thinking about this problem ...
Go unfortunately has no algebraic types - otherwise you could just make a channel of "either" Line or Err or Event and be done with it.
So, one solution is to add a new field called Event:
type Line struct {
Text string
Time time.Time
Err error // Error from tail
Event Event // eg: reopen event
}
Just like Err, Event will be nil most of the time. If we had algebraic types (or union types) support, these fields need be put in the Line struct. The user code will now have to do two checks — if line.Err != nil; if line.Event != nil — before getting to process the actual lines. However this seems like bad API.
Hi,
Nice library!
I'd like to be able to tell when the file is reopened. However having to deal with an event (channel, error code, ...) in case of reopen feels like a kludge. What about simply adding a byte position of the start of each line in the
Line
structure. There is already the timestamp. This way users can detect when the file was reopened because the position is no longer monotonically increasing.What do you think?
The text was updated successfully, but these errors were encountered: