[ARVADOS] updated: 8b97af24fe40673cfa7505028e305a39708a96e0

Git user git at public.curoverse.com
Wed May 25 23:06:59 EDT 2016


Summary of changes:
 sdk/go/arvados/duration.go                | 31 +++++++++++++++++++++++++++++++
 services/keep-balance/balance_run_test.go |  2 +-
 services/keep-balance/duration.go         | 23 -----------------------
 services/keep-balance/main.go             |  4 ++--
 4 files changed, 34 insertions(+), 26 deletions(-)
 create mode 100644 sdk/go/arvados/duration.go
 delete mode 100644 services/keep-balance/duration.go

       via  8b97af24fe40673cfa7505028e305a39708a96e0 (commit)
       via  5838ef2b29bcc7e65133e482a011649b8464e511 (commit)
      from  2e3dfa6394ea17ab266b4c6e2346a469c63efb74 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 8b97af24fe40673cfa7505028e305a39708a96e0
Author: Tom Clegg <tom at curoverse.com>
Date:   Wed May 25 22:44:17 2016 -0400

    9162: Move Duration to SDK

diff --git a/services/keep-balance/duration.go b/sdk/go/arvados/duration.go
similarity index 79%
rename from services/keep-balance/duration.go
rename to sdk/go/arvados/duration.go
index 1a06770..1639c58 100644
--- a/services/keep-balance/duration.go
+++ b/sdk/go/arvados/duration.go
@@ -1,6 +1,7 @@
-package main
+package arvados
 
 import (
+	"encoding/json"
 	"fmt"
 	"time"
 )
@@ -9,6 +10,7 @@ import (
 // a number of nanoseconds.
 type Duration time.Duration
 
+// UnmarshalJSON implements json.Unmarshaler
 func (d *Duration) UnmarshalJSON(data []byte) error {
 	if data[0] == '"' {
 		dur, err := time.ParseDuration(string(data[1 : len(data)-1]))
@@ -18,10 +20,12 @@ func (d *Duration) UnmarshalJSON(data []byte) error {
 	return fmt.Errorf("duration must be given as a string like \"600s\" or \"1h30m\"")
 }
 
+// MarshalJSON implements json.Marshaler
 func (d *Duration) MarshalJSON() ([]byte, error) {
 	return json.Marshal(d.String())
 }
 
+// String implements fmt.Stringer
 func (d Duration) String() string {
 	return time.Duration(d).String()
 }
diff --git a/services/keep-balance/balance_run_test.go b/services/keep-balance/balance_run_test.go
index 4b04f8a..a138d91 100644
--- a/services/keep-balance/balance_run_test.go
+++ b/services/keep-balance/balance_run_test.go
@@ -359,7 +359,7 @@ func (s *runSuite) TestRunForever(c *check.C) {
 	pullReqs := s.stub.serveKeepstorePull()
 
 	stop := make(chan interface{})
-	s.config.RunPeriod = duration(time.Millisecond)
+	s.config.RunPeriod = arvados.Duration(time.Millisecond)
 	go RunForever(s.config, opts, stop)
 
 	// Each run should send 4 clear trash lists + 4 pull lists + 4
diff --git a/services/keep-balance/main.go b/services/keep-balance/main.go
index 48b1a74..1d7152e 100644
--- a/services/keep-balance/main.go
+++ b/services/keep-balance/main.go
@@ -25,7 +25,7 @@ type Config struct {
 	KeepServiceList arvados.KeepServiceList
 
 	// How often to check
-	RunPeriod duration
+	RunPeriod arvados.Duration
 }
 
 // RunOptions controls runtime behavior. The flags/options that belong
@@ -71,7 +71,7 @@ func main() {
 	if *serviceListPath != "" {
 		mustReadJSON(&config.KeepServiceList, *serviceListPath)
 	}
-	if !*once && config.RunPeriod == duration(0) {
+	if !*once && config.RunPeriod == arvados.Duration(0) {
 		log.Fatal("You must either use the -once flag or specify a RunPeriod in your config file")
 	}
 

commit 5838ef2b29bcc7e65133e482a011649b8464e511
Author: Tom Clegg <tom at curoverse.com>
Date:   Wed May 25 22:39:43 2016 -0400

    9162: Export Duration

diff --git a/services/keep-balance/duration.go b/services/keep-balance/duration.go
index 0bf0fb5..1a06770 100644
--- a/services/keep-balance/duration.go
+++ b/services/keep-balance/duration.go
@@ -5,19 +5,23 @@ import (
 	"time"
 )
 
-// duration is time.Duration but can be given in a config file as
-// "600s" rather than a number of nanoseconds.
-type duration time.Duration
+// Duration is time.Duration but looks like "12s" in JSON, rather than
+// a number of nanoseconds.
+type Duration time.Duration
 
-func (d *duration) UnmarshalJSON(data []byte) error {
+func (d *Duration) UnmarshalJSON(data []byte) error {
 	if data[0] == '"' {
 		dur, err := time.ParseDuration(string(data[1 : len(data)-1]))
-		*d = duration(dur)
+		*d = Duration(dur)
 		return err
 	}
 	return fmt.Errorf("duration must be given as a string like \"600s\" or \"1h30m\"")
 }
 
-func (d duration) String() string {
+func (d *Duration) MarshalJSON() ([]byte, error) {
+	return json.Marshal(d.String())
+}
+
+func (d Duration) String() string {
 	return time.Duration(d).String()
 }

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list