github.com/Pankov404/juju@v0.0.0-20150703034450-be266991dceb/state/lease/clock.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package lease
     5  
     6  import (
     7  	"time"
     8  )
     9  
    10  // SystemClock exposes wall-clock time as returned by time.Now.
    11  type SystemClock struct{}
    12  
    13  // Now is part of the Clock interface.
    14  func (SystemClock) Now() time.Time {
    15  	return time.Now()
    16  }
    17  
    18  // Alarm returns a channel that will send a value at some point after
    19  // the supplied time.
    20  func (clock SystemClock) Alarm(t time.Time) <-chan time.Time {
    21  	return time.After(t.Sub(clock.Now()))
    22  }