Rename periodic.Stoper to periodic.Stopper

This commit is contained in:
Eric Lippmann 2021-11-05 09:33:44 +01:00
parent 886c60c95a
commit ea74dc172a
4 changed files with 6 additions and 6 deletions

View file

@ -547,7 +547,7 @@ func (db *DB) GetSemaphoreForTable(table string) *semaphore.Weighted {
}
}
func (db *DB) log(ctx context.Context, query string, counter *com.Counter) periodic.Stoper {
func (db *DB) log(ctx context.Context, query string, counter *com.Counter) periodic.Stopper {
return periodic.Start(ctx, db.logger.Interval(), func(tick periodic.Tick) {
if count := counter.Reset(); count > 0 {
db.logger.Debugf("Executed %q with %d rows", query, count)

View file

@ -121,7 +121,7 @@ func (s Sync) initSync(ctx context.Context, objectType string) error {
}
// log periodically logs sync's workload.
func (s Sync) log(ctx context.Context, objectType string, counter *com.Counter) periodic.Stoper {
func (s Sync) log(ctx context.Context, objectType string, counter *com.Counter) periodic.Stopper {
return periodic.Start(ctx, s.logger.Interval(), func(_ periodic.Tick) {
if count := counter.Reset(); count > 0 {
s.logger.Infof("Synced %d %s overdue indicators", count, objectType)

View file

@ -221,7 +221,7 @@ func (c Client) YieldAll(ctx context.Context, subject *common.SyncSubject) (<-ch
return desired, com.WaitAsync(g)
}
func (c *Client) log(ctx context.Context, key string, counter *com.Counter) periodic.Stoper {
func (c *Client) log(ctx context.Context, key string, counter *com.Counter) periodic.Stopper {
return periodic.Start(ctx, c.logger.Interval(), func(tick periodic.Tick) {
// We may never get to progress logging here,
// as fetching should be completed before the interval expires,

View file

@ -11,9 +11,9 @@ type Option interface {
apply(*periodic)
}
// Stoper implements the Stop method,
// Stopper implements the Stop method,
// which stops a periodic task from Start().
type Stoper interface {
type Stopper interface {
Stop() // Stops a periodic task.
}
@ -36,7 +36,7 @@ func OnStop(f func(Tick)) Option {
// which executes the given callback after each tick.
// Call Stop() on the return value in order to stop the ticker and to release associated resources.
// The interval must be greater than zero.
func Start(ctx context.Context, interval time.Duration, callback func(Tick), options ...Option) Stoper {
func Start(ctx context.Context, interval time.Duration, callback func(Tick), options ...Option) Stopper {
t := &periodic{
interval: interval,
callback: callback,