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.
This commit is contained in:
Matt Jaffee 2020-04-21 12:29:19 -05:00
parent 5e29effa93
commit a3c5f4822e
No known key found for this signature in database
GPG key ID: 08A3DFFF987B11BF
2 changed files with 3 additions and 4 deletions

View file

@ -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),
})
}

View file

@ -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