diff options
author | Daniel Langesten <daniel.langest@gmail.com> | 2015-03-10 14:29:02 +0100 |
---|---|---|
committer | Daniel Langesten <daniel.langest@gmail.com> | 2015-03-10 14:29:02 +0100 |
commit | f4d1964a8bbe26326119f7cc9782ca51eb9fa64e (patch) | |
tree | 36c547cc28a830a46984f7ea5a004a2f069ec89b | |
parent | 40b81c6cbf5b427fda223aade06c1e933547a91f (diff) |
now reading volume information from config
-rw-r--r-- | datastructs.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/datastructs.go b/datastructs.go index 25220c5..a4ac45c 100644 --- a/datastructs.go +++ b/datastructs.go @@ -1,6 +1,7 @@ package main import ( + "errors" "time" ) @@ -12,8 +13,14 @@ type RawData struct { packetSize int } -func (rd *RawData) getVolSize() string { - return "medium" +func (rd *RawData) getVolSize(conf Config) (string, error) { + for _, volume := range conf.Volumes { + if volume.Lower <= rd.packetSize && + (rd.packetSize < volume.Upper || volume.Upper == 0) { + return volume.Size, nil + } + } + return "N/A", errors.New("Could not find a fitting size volume") } type CleanData struct { |