Skip to content

Commit

Permalink
Merge pull request #303 from howbazaar/use-juju-clock
Browse files Browse the repository at this point in the history
Merge pull request #303 from howbazaar/use-juju-clock


Remove the clock interface and type from utils.

These are now available in "github.com/juju/clock".

Drive by fix for some licences.
  • Loading branch information
jujubot authored Aug 20, 2018
2 parents 9dfc6db + 4fd4c23 commit bf9cc5b
Show file tree
Hide file tree
Showing 19 changed files with 37 additions and 188 deletions.
2 changes: 1 addition & 1 deletion cert/cert.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2012, 2013 Canonical Ltd.
// Copyright 2016 Cloudbase solutions
// Licensed under the AGPLv3, see LICENCE file for details.
// Licensed under the LGPLv3, see LICENCE file for details.

package cert

Expand Down
2 changes: 1 addition & 1 deletion cert/cert_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2012, 2013 Canonical Ltd.
// Copyright 2016 Cloudbase solutions
// Licensed under the AGPLv3, see LICENCE file for details.
// Licensed under the LGPLv3, see LICENCE file for details.

package cert_test

Expand Down
2 changes: 1 addition & 1 deletion cert/exports_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2016 Canonical ltd.
// Copyright 2016 Cloudbase solutions
// Licensed under the lgplv3, see licence file for details.
// Licensed under the LGPLv3, see LICENCE file for details.

package cert

Expand Down
53 changes: 0 additions & 53 deletions clock/clock.go

This file was deleted.

22 changes: 0 additions & 22 deletions clock/monotonic/monotonic.go

This file was deleted.

4 changes: 0 additions & 4 deletions clock/monotonic/monotonic.s

This file was deleted.

33 changes: 0 additions & 33 deletions clock/monotonic/monotonic_test.go

This file was deleted.

47 changes: 0 additions & 47 deletions clock/wall.go

This file was deleted.

5 changes: 4 additions & 1 deletion context.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2018 Canonical Ltd.
// Licensed under the LGPLv3, see LICENCE file for details.

package utils

import (
Expand All @@ -7,7 +10,7 @@ import (

"golang.org/x/net/context"

"github.com/juju/utils/clock"
"github.com/juju/clock"
)

// timerCtx is an implementation of context.Context that
Expand Down
13 changes: 8 additions & 5 deletions context_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2018 Canonical Ltd.
// Licensed under the LGPLv3, see LICENCE file for details.

package utils_test

import (
Expand All @@ -6,7 +9,7 @@ import (

"golang.org/x/net/context"

"github.com/juju/testing"
"github.com/juju/clock/testclock"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"

Expand All @@ -21,7 +24,7 @@ var _ = gc.Suite(&contextSuite{})
// in the Go standard library.

func (*contextSuite) TestDeadline(c *gc.C) {
clk := testing.NewClock(time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC))
clk := testclock.NewClock(time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC))
ctx, cancel := utils.ContextWithDeadline(context.Background(), clk, clk.Now().Add(50*time.Millisecond))
defer cancel()
c.Assert(fmt.Sprint(ctx), gc.Equals, `context.Background.WithDeadline(2000-01-01 00:00:00.05 +0000 UTC [50ms])`)
Expand All @@ -47,7 +50,7 @@ func (*contextSuite) TestDeadline(c *gc.C) {
}

func (*contextSuite) TestTimeout(c *gc.C) {
clk := testing.NewClock(time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC))
clk := testclock.NewClock(time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC))
ctx, _ := utils.ContextWithTimeout(context.Background(), clk, 50*time.Millisecond)
c.Assert(fmt.Sprint(ctx), gc.Equals, `context.Background.WithDeadline(2000-01-01 00:00:00.05 +0000 UTC [50ms])`)
testContextDeadline(c, ctx, "WithTimeout", clk, 1, 50*time.Millisecond)
Expand All @@ -63,7 +66,7 @@ func (*contextSuite) TestTimeout(c *gc.C) {
}

func (*contextSuite) TestCanceledTimeout(c *gc.C) {
clk := testing.NewClock(time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC))
clk := testclock.NewClock(time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC))
ctx, _ := utils.ContextWithTimeout(context.Background(), clk, time.Second)
o := otherContext{ctx}
ctx, cancel := utils.ContextWithTimeout(o, clk, 2*time.Second)
Expand All @@ -77,7 +80,7 @@ func (*contextSuite) TestCanceledTimeout(c *gc.C) {
c.Assert(ctx.Err(), gc.Equals, context.Canceled)
}

func testContextDeadline(c *gc.C, ctx context.Context, name string, clk *testing.Clock, waiters int, failAfter time.Duration) {
func testContextDeadline(c *gc.C, ctx context.Context, name string, clk *testclock.Clock, waiters int, failAfter time.Duration) {
err := clk.WaitAdvance(failAfter, 0, waiters)
c.Assert(err, jc.ErrorIsNil)
select {
Expand Down
25 changes: 13 additions & 12 deletions dependencies.tsv
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
github.com/juju/ansiterm git b99631de12cf04a906c1d4e4ec54fb86eae5863d 2016-09-07T23:45:32Z
github.com/juju/cmd git ad2437ef0ef282ae26e482eb1e44c02532bae1ba 2017-06-22T12:53:07Z
github.com/juju/clock git d293bb356ca441f16b59562295cca74478966757 2018-05-24T02:22:03Z
github.com/juju/cmd git e74f39857ca013cf63947ba2843806f7afdd380d 2017-11-07T07:04:56Z
github.com/juju/errors git 1b5e39b83d1835fa480e0c2ddefb040ee82d58b3 2015-09-16T12:56:42Z
github.com/juju/gnuflag git 4e76c56581859c14d9d87e1ddbe29e1c0f10195f 2016-08-09T16:52:14Z
github.com/juju/gnuflag git 2ce1bb71843d6d179b3f1c1c9cb4a72cd067fc65 2017-11-13T08:59:48Z
github.com/juju/httpprof git 14bf14c307672fd2456bdbf35d19cf0ccd3cf565 2014-12-17T16:00:36Z
github.com/juju/loggo git 8232ab8918d91c72af1a9fb94d3edbe31d88b790 2017-06-05T01:46:07Z
github.com/juju/mutex git 59c26ee163447c5c57f63ff71610d433862013de 2016-06-17T01:09:07Z
github.com/juju/retry git 62c62032529169c7ec02fa48f93349604c345e1f 2015-10-29T02:48:21Z
github.com/juju/testing git 2fe0e88cf2321d801acedd2b4f0d7f63735fb732 2017-06-08T05:44:51Z
github.com/juju/mutex git 1fe2a4bf0a3a2c10881501233ff7c6aed7790082 2017-11-10T02:00:13Z
github.com/juju/retry git 1998d01ba1c3eeb4a4728c4a50660025b2fe7c8f 2016-09-28T20:18:58Z
github.com/juju/testing git b0b89ba330f22548fba865dd0e1d85a44e9cd7dd 2018-08-20T04:02:00Z
github.com/juju/version git 1f41e27e54f21acccf9b2dddae063a782a8a7ceb 2016-10-31T05:19:06Z
github.com/julienschmidt/httprouter git 77a895ad01ebc98a4dc95d8355bc825ce80a56f6 2015-10-13T22:55:20Z
github.com/lunixbochs/vtclean git 4fbf7632a2c6d3fbdb9931439bdbbeded02cbe36 2016-01-25T03:51:06Z
Expand All @@ -17,14 +18,14 @@ github.com/masterzen/xmlpath git 13f4951698adc0fa9c1dda3e275d489a24201161 2014-0
github.com/mattn/go-colorable git ed8eb9e318d7a84ce5915b495b7d35e0cfe7b5a8 2016-07-31T23:54:17Z
github.com/mattn/go-isatty git 66b8e73f3f5cda9f96b69efd03dd3d7fc4a5cdb8 2016-08-06T12:27:52Z
github.com/nu7hatch/gouuid git 179d4d0c4d8d407a32af483c2354df1d2c91e6c3 2013-12-21T20:05:32Z
golang.org/x/crypto git 96846453c37f0876340a66a47f3f75b1f3a6cd2d 2017-04-21T04:31:20Z
golang.org/x/net git a04bdaca5b32abe1c069418fb7088ae607de5bd0 2017-10-04T03:46:48Z
golang.org/x/sys git 7a6e5648d140666db5d920909e082ca00a87ba2c 2017-02-01T05:12:45Z
golang.org/x/text git 88f656faf3f37f690df1a32515b479415e1a6769 2017-11-02T19:24:21Z
golang.org/x/crypto git 650f4a345ab4e5b245a3034b110ebc7299e68186 2018-02-14T00:00:28Z
golang.org/x/net git 61147c48b25b599e5b561d2e9c4f3e1ef489ca41 2018-04-06T21:48:16Z
golang.org/x/sys git 37707fdb30a5b38865cfb95e5aab41707daec7fd 2018-02-02T13:58:01Z
golang.org/x/text git 2910a502d2bf9e43193af9d68ca516529614eed3 2016-07-26T16:48:57Z
gopkg.in/check.v1 git 4f90aeace3a26ad7021961c297b22c42160c7b25 2016-01-05T16:49:36Z
gopkg.in/errgo.v1 git 442357a80af5c6bf9b6d51ae791a39c3421004f3 2016-12-22T12:58:16Z
gopkg.in/httprequest.v1 git 35158f716c228fdf58b5a5b80cf331302d10160a 2017-11-03T09:19:05Z
gopkg.in/juju/names.v2 git 0f8ae7499c60de56e4cb4c5eabe2d504615a18ca 2017-05-15T22:48:47Z
gopkg.in/httprequest.v1 git 1a21782420ea13c3c6fb1d03578f446b3248edb1 2018-03-08T16:26:44Z
gopkg.in/juju/names.v2 git c43e8bdf2f4915a7019a2f8ad561af1498731a21 2018-05-16T01:04:14Z
gopkg.in/mgo.v2 git f2b6f6c918c452ad107eec89615f074e3bd80e33 2016-08-18T01:52:18Z
gopkg.in/tomb.v1 git dd632973f1e7218eb1089048e0798ec9ae7dceb8 2014-10-24T13:56:13Z
gopkg.in/yaml.v2 git a3f3340b5840cee44f372bddb5880fcbc419b46a 2017-02-08T14:18:51Z
gopkg.in/yaml.v2 git 1be3d31502d6eabc0dd7ce5b0daab022e14a5538 2017-07-12T05:45:46Z
2 changes: 1 addition & 1 deletion exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (
"syscall"
"time"

"github.com/juju/clock"
"github.com/juju/errors"
"github.com/juju/loggo"
"github.com/juju/utils/clock"
)

var logger = loggo.GetLogger("juju.util.exec")
Expand Down
2 changes: 1 addition & 1 deletion exec/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"

"github.com/juju/utils/clock"
"github.com/juju/clock"
"github.com/juju/utils/exec"
)

Expand Down
2 changes: 1 addition & 1 deletion limiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"math/rand"
"time"

"github.com/juju/utils/clock"
"github.com/juju/clock"
)

type empty struct{}
Expand Down
3 changes: 2 additions & 1 deletion limiter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"time"

"github.com/juju/clock/testclock"
"github.com/juju/testing"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
Expand Down Expand Up @@ -81,7 +82,7 @@ func (*limiterSuite) TestAcquireWaitBlocksUntilRelease(c *gc.C) {
}

func (*limiterSuite) TestAcquirePauses(c *gc.C) {
clk := testing.NewClock(time.Now())
clk := testclock.NewClock(time.Now())
l := utils.NewLimiterWithPause(2, 10*time.Millisecond, 20*time.Millisecond, clk)
acquired := make(chan bool, 1)
start := make(chan bool, 0)
Expand Down
2 changes: 1 addition & 1 deletion ssh/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"syscall"
"time"

"github.com/juju/clock"
"github.com/juju/errors"
"github.com/juju/utils/clock"
utilexec "github.com/juju/utils/exec"
)

Expand Down
2 changes: 1 addition & 1 deletion ssh/ssh_gocrypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import (
"sync"
"time"

"github.com/juju/clock"
"github.com/juju/errors"
"github.com/juju/mutex"
"github.com/juju/utils"
"github.com/juju/utils/clock"
"golang.org/x/crypto/ssh"
"golang.org/x/crypto/ssh/knownhosts"
"golang.org/x/crypto/ssh/terminal"
Expand Down
2 changes: 1 addition & 1 deletion timer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"math/rand"
"time"

"github.com/juju/utils/clock"
"github.com/juju/clock"
)

// Countdown implements a timer that will call a provided function.
Expand Down
2 changes: 1 addition & 1 deletion timer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (

gc "gopkg.in/check.v1"

"github.com/juju/clock"
"github.com/juju/testing"
jc "github.com/juju/testing/checkers"
"github.com/juju/utils"
"github.com/juju/utils/clock"
)

type TestStdTimer struct {
Expand Down

0 comments on commit bf9cc5b

Please sign in to comment.