From a3c5f4822eeb5cadf4b571729cc86f7faa5d0b1a Mon Sep 17 00:00:00 2001 From: Matt Jaffee Date: Tue, 21 Apr 2020 12:29:19 -0500 Subject: [PATCH] keep the zone info back in deadline strings (but output in UTC) instead of defining them as being in UTC, but not including the zone info, we will keep the standard format with zone info, but always output the time in UTC. This means that we can parse incoming deadlines that happen to have zone information, though I don't think we ever need to. --- transaction.go | 6 ++---- transaction.md | 1 + 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/transaction.go b/transaction.go index b8c25bb94..624161f80 100644 --- a/transaction.go +++ b/transaction.go @@ -390,8 +390,6 @@ func CompareTransactions(t1, t2 Transaction) error { return nil } -const RFC3339NanoNoZone = "2006-01-02T15:04:05.999999999" - func (trns *Transaction) UnmarshalJSON(b []byte) error { tmp := &struct { ID string `json:"id"` @@ -426,7 +424,7 @@ func (trns *Transaction) UnmarshalJSON(b []byte) error { } if tmp.Deadline != "" { - trns.Deadline, err = time.ParseInLocation(RFC3339NanoNoZone, tmp.Deadline, time.UTC) + trns.Deadline, err = time.Parse(time.RFC3339Nano, tmp.Deadline) } return errors.Wrap(err, "parsing deadline") } @@ -443,6 +441,6 @@ func (trns *Transaction) MarshalJSON() ([]byte, error) { Active: trns.Active, Exclusive: trns.Exclusive, Timeout: trns.Timeout.String(), - Deadline: trns.Deadline.In(time.UTC).Format(RFC3339NanoNoZone), + Deadline: trns.Deadline.In(time.UTC).Format(time.RFC3339Nano), }) } diff --git a/transaction.md b/transaction.md index c3bdc27e3..aeefad8bc 100644 --- a/transaction.md +++ b/transaction.md @@ -165,6 +165,7 @@ goes through API (and is passed directly to Server). (unimplemented) - [ ] implement transaction id in header - [x] propagate context - [ ] implement and use persistent transaction store rather than inmem. + - [ ] implement some method for syncing transaction stores - [ ] update go-pilosa/gpexp to actually USE transactions - [ ] update IDK to use updated go-pilosa - [ ] external testing with e.g. curl