-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
in_tail: position_file: Define path based equalities on TargetInfo #3391
Closed
Closed
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -282,4 +282,29 @@ def build_files(file) | |
assert_equal 2, f.read_inode | ||
end | ||
end | ||
|
||
sub_test_case "TargetInfo" do | ||
def test_equal | ||
t1 = Fluent::Plugin::TailInput::TargetInfo.new("test", 1234) | ||
t2 = Fluent::Plugin::TailInput::TargetInfo.new("test", 1235) | ||
|
||
assert_equal t1, t2 | ||
end | ||
|
||
def test_eql? | ||
t1 = Fluent::Plugin::TailInput::TargetInfo.new("test", 1234) | ||
t2 = Fluent::Plugin::TailInput::TargetInfo.new("test", 5321) | ||
|
||
assert do | ||
t1.eql? t2 | ||
end | ||
end | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To emphasize the difference of eql? and equal? behavior, how about adding one more test case using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
def test_hash | ||
t1 = Fluent::Plugin::TailInput::TargetInfo.new("test", 1234) | ||
t2 = Fluent::Plugin::TailInput::TargetInfo.new("test", 7321) | ||
|
||
assert_equal t1.hash, t2.hash | ||
end | ||
end | ||
end |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure follow_inodes feature but does it work well also on
@follow_inodes
?I think that keys of
@tails
should be inode on@follow_inodes
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or paths are updated by
update_watcher
on rotation so paths are never duplicate?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take a look on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still checking it too.
Probably above my concern is wrong, it should be path maybe.
Otherwise
update_watcher
can't discard oldTailWather
from@tails
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Memo:
Instead of overriding them, I thought using
target_info.path
as a key is more straightforward and understandable:@tails[target_info.path]
But it's also wrong.
TargetInfo
is referred byeach_keys
so keys have to beTargetInfo
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, probably it's O.K. as a first aid but I think more refactoring is needed to make easy to understand in the future 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! I'm also considering to use it to be made easier to understand, but overriding equality on TargetInfo is one of the simplest way to dispose discarded old TailWatcher correctly. (This strategy doesn't request more refactoring.)