juju: github.com/juju/juju/core/globalclock Index | Files

package globalclock

import "github.com/juju/juju/core/globalclock"


Package Files



var (
    // ErrConcurrentUpdate is returned by Updater.Advance when the
    // clock value has been changed since the last read.
    ErrConcurrentUpdate = errors.New("clock was updated concurrently, retry")

    // ErrTimeout is returned by Updater.Advance if the attempt to
    // update the global clock timed out - in that case the advance
    // should be tried again.
    ErrTimeout = errors.New("clock update timed out, retry")

func IsConcurrentUpdate Uses

func IsConcurrentUpdate(err error) bool

IsConcurrentUpdate returns whether the specified error represents ErrConcurrentUpdate (even if it's wrapped).

func IsTimeout Uses

func IsTimeout(err error) bool

IsTimeout returns whether the specified error represents ErrTimeout (even if it's wrapped).

type Updater Uses

type Updater interface {
    // Advance adds the given duration to the global clock, ensuring
    // that the clock has not been updated concurrently.
    // Advance will return ErrConcurrentUpdate if another updater
    // updates the clock concurrently. In this case, the updater
    // will refresh its view of the clock, and the caller can
    // attempt Advance later.
    // If Advance returns any error other than ErrConcurrentUpdate or
    // ErrTimeout the Updater should be considered invalid, and the
    // caller should obtain a new Updater. Failing to do so could lead
    // to non-monotonic time, since there is no way of knowing in
    // general whether or not the database was updated.
    Advance(d time.Duration, stop <-chan struct{}) error

Updater provides a means of updating the global clock time.

Package globalclock imports 2 packages (graph) and is imported by 21 packages. Updated 2019-03-18. Refresh now. Tools for package owners.