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

MYST-323 Increase stats update frequency #180

Merged
merged 8 commits into from Feb 26, 2018

Conversation

Projects
None yet
2 participants
@donce
Copy link
Contributor

commented Feb 26, 2018

No description provided.

@donce donce requested review from shroomist, tadovas, interro and zolia Feb 26, 2018

@@ -39,8 +39,11 @@ func ConfigureVpnClientFactory(
go statsSender(stats)
return nil
}

statsHandler := bytescount.NewCompositeStatsHandler(statsSaver, asyncStatsSender)
asyncIntervalStatsSender, err := bytescount.NewIntervalStatsHandler(asyncStatsSender, time.Now, 60)

This comment has been minimized.

Copy link
@tadovas

tadovas Feb 26, 2018

Member

Maybe asyncIntervalStatsSender -> just intervalStatsSender?

This comment has been minimized.

Copy link
@donce

donce Feb 26, 2018

Author Contributor

Done.

if interval < 0 {
return nil, errors.New("Invalid 'interval' parameter")
}
var lastTime *time.Time = nil

This comment has been minimized.

Copy link
@tadovas

tadovas Feb 26, 2018

Member

var lastTime = &time.Time{}. No need to check for nil, also it would be initialized to zero (unix style) and will trigger first call to handler. Maybe even pointer is not needed here.

This comment has been minimized.

Copy link
@donce

donce Feb 26, 2018

Author Contributor

Added boolean var

var lastTime *time.Time = nil
return func(sessionStats SessionStats) error {
now := clock()
if lastTime == nil || (now.Sub(*lastTime)) >= interval {

This comment has been minimized.

Copy link
@tadovas

tadovas Feb 26, 2018

Member

Maybe lastTime.Add(interval) < now ?

This comment has been minimized.

Copy link
@donce

donce Feb 26, 2018

Author Contributor

Not sure if this is better, especially since you've made a mistake in your example: >= should be used instead of < :D

This comment has been minimized.

Copy link
@tadovas

tadovas Feb 26, 2018

Member

No I didn't.

This comment has been minimized.

Copy link
@donce

donce Feb 26, 2018

Author Contributor

Yeah, you didn't - it's more confusing than I initially thought :D
Comparing passed time with interval time seems much easier.

)

// NewIntervalStatsHandler creates and returns composite handler, which invokes internal handler at given interval
func NewIntervalStatsHandler(handler SessionStatsHandler, clock func() time.Time, interval time.Duration) (SessionStatsHandler, error) {

This comment has been minimized.

Copy link
@tadovas

tadovas Feb 26, 2018

Member

clock -> currentTime ? It would look nicer now:=currentTime()

This comment has been minimized.

Copy link
@donce

donce Feb 26, 2018

Author Contributor

Done.

@tadovas
Copy link
Member

left a comment

LGTM

@donce donce merged commit 37218d9 into master Feb 26, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@donce donce deleted the feature/MYST-323-increase-stats-update-frequency branch Feb 26, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.