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

Clock api for incremental second unit counter #1425

Merged
merged 2 commits into from
Jan 20, 2017

Conversation

tagomoris
Copy link
Member

Currently there are many code to use Time.now to control flush timing and event invoke timing.
It's basically wrong, because time may move to future or past by time adjustment, or affected by leap seconds (and Timecop).
We can use Process.clock_gettime to avoid this problem, but it's a bit troublesome to specify clock type available. It's too much and too raw for almost core code and plugins. Using Process.clock_gettime is also not controlled by test code.

So, this change will introduce a new internal API to provide clock value, which can be controlled to be frozen for tests.

@tagomoris tagomoris added enhancement Feature request or improve operations v0.14 labels Jan 19, 2017
@tagomoris tagomoris self-assigned this Jan 19, 2017
@tagomoris
Copy link
Member Author

@repeatedly could you review this change?

c0 = Fluent::Clock.now
t0 = Time.now
t1 = t0 - 30
assert_kind_of Time, t1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This checks ruby spec, not fluentd code.
So it seems not needed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true, but it assures this test code uses Time argument.
Assertions are sometimes used for such usage.

end

def self.freeze(dst = nil, &block)
return freeze_block(dst, &block) if block_given?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if block is enough but trivial

@repeatedly
Copy link
Member

LGTM and add comments.

@tagomoris
Copy link
Member Author

Let me merge this right now... Windows CI is failing with known timing bug of test code (and it's already fixed in #1426)

@tagomoris tagomoris merged commit 25ad150 into master Jan 20, 2017
@tagomoris tagomoris deleted the clock-api-for-incremental-second-unit-counter branch January 20, 2017 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request or improve operations v0.14
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants