diff --git a/eliofile/eliofile.go b/eliofile/eliofile.go index cd51155..442f4ce 100644 --- a/eliofile/eliofile.go +++ b/eliofile/eliofile.go @@ -16,7 +16,14 @@ type filedata struct { filename string dt time.Time } -type ElioHandleFunc func(filename string) bool + +// Daten über Channel aus der Goroutine ausführen. CounterID stellt sicher, dass das Herkunftsland der Daten bekannt ist. +type CountryCsvData struct { + CountryID string + Data []string +} + +type ElioHandleFunc func(filename string, data chan<- CountryCsvData) bool type ElioDateiFoo struct { process ElioHandleFunc @@ -68,6 +75,9 @@ func (f *ElioDateiFoo) ScanCsv() { } } } + + //BufferedChannel mit Platz für 10 Datensätzen + dataChannel := make(chan CountryCsvData, 10) for _, v := range filemap { f.mu.RLock() _, ok := f.haveDone[v.filename] @@ -75,9 +85,10 @@ func (f *ElioDateiFoo) ScanCsv() { if ok { break } + //Todo: Goroutine Einbauen, die alte Datensätze aus der Map entfernt f.mu.Lock() f.haveDone[v.filename] = time.Now() f.mu.Unlock() - go f.process(v.filename) + go f.process(v.filename, dataChannel) } }