cf1f3625b4
Our testing so far indicates that ugorji/go/codec maintains backward compatiblity with the version we are using now, for purposes of Nomad serialization. Using latest ugorji/go allows us to get back to using upstream library, get get the optimizations benefits in RPC paths (including code generation optimizations). ugorji/go introduced two significant changes: * time binary format indebb8e2d2e
. Setting `h.BasicHandle.TimeNotBuiltin = true` restores old behavior * ugorji/go started honoring `json` tag as well: v1.1.4 is the latest but has a bug in handling RawString that's fixed ind09a80c1e0
.
28 lines
647 B
Cheetah
28 lines
647 B
Cheetah
{{.Label}}:
|
|
switch timeout{{.Sfx}} := z.EncBasicHandle().ChanRecvTimeout; {
|
|
case timeout{{.Sfx}} == 0: // only consume available
|
|
for {
|
|
select {
|
|
case b{{.Sfx}} := <-{{.Chan}}:
|
|
{{ .Slice }} = append({{.Slice}}, b{{.Sfx}})
|
|
default:
|
|
break {{.Label}}
|
|
}
|
|
}
|
|
case timeout{{.Sfx}} > 0: // consume until timeout
|
|
tt{{.Sfx}} := time.NewTimer(timeout{{.Sfx}})
|
|
for {
|
|
select {
|
|
case b{{.Sfx}} := <-{{.Chan}}:
|
|
{{.Slice}} = append({{.Slice}}, b{{.Sfx}})
|
|
case <-tt{{.Sfx}}.C:
|
|
// close(tt.C)
|
|
break {{.Label}}
|
|
}
|
|
}
|
|
default: // consume until close
|
|
for b{{.Sfx}} := range {{.Chan}} {
|
|
{{.Slice}} = append({{.Slice}}, b{{.Sfx}})
|
|
}
|
|
}
|