diff options
author | Markus Grüneis <gimpf@gimpf.org> | 2014-10-18 21:58:37 +0200 |
---|---|---|
committer | Markus Grüneis <gimpf@gimpf.org> | 2014-10-18 21:59:22 +0200 |
commit | 26177d58b82bc11f080ee2dafca366080f084c6b (patch) | |
tree | ca7e40d6aa560b42e03cce8d90989322d6397619 /src/hub/src/spreadspace.org/sfive/s5cvt.go | |
parent | update sample data (diff) |
hub: add basic filter-by-time support
Diffstat (limited to 'src/hub/src/spreadspace.org/sfive/s5cvt.go')
-rw-r--r-- | src/hub/src/spreadspace.org/sfive/s5cvt.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/hub/src/spreadspace.org/sfive/s5cvt.go b/src/hub/src/spreadspace.org/sfive/s5cvt.go index 24b458a..e908bc6 100644 --- a/src/hub/src/spreadspace.org/sfive/s5cvt.go +++ b/src/hub/src/spreadspace.org/sfive/s5cvt.go @@ -13,6 +13,10 @@ type StatsEncoder interface { Encode(data StatisticsData) []byte } +type FilterDecoder interface { + Decode(jsonString []byte) (StatsFilter, error) +} + type StatefulDecoder struct { sourceId SourceId } @@ -21,6 +25,8 @@ type PlainDecoder struct{} type PlainEncoder struct{} +type filterDecoder struct{} + func NewStatefulDecoder(jsonString []byte) (decoder StatsDecoder, err error) { res := new(StatefulDecoder) err = json.Unmarshal(jsonString, &res.sourceId) @@ -38,6 +44,10 @@ func NewPlainDecoder() (decoder StatsDecoder) { return new(PlainDecoder) } +func NewFilterDecoder() (decoder FilterDecoder) { + return new(filterDecoder) +} + func (self *StatefulDecoder) Decode(jsonString []byte) (dat StatisticsData, err error) { dat.CopyFrom(&self.sourceId) err = json.Unmarshal(jsonString, &dat) @@ -58,3 +68,8 @@ func (self *PlainEncoder) Encode(data *StatisticsData) []byte { } return res } + +func (self *filterDecoder) Decode(jsonString []byte) (dat StatsFilter, err error) { + err = json.Unmarshal(jsonString, &dat) + return +} |