From dd6cb28e9aad678b5a99156455ea1841a1f1c340 Mon Sep 17 00:00:00 2001 From: Marco Kittel Date: Sun, 29 Jun 2025 08:20:36 +0200 Subject: [PATCH] =?UTF-8?q?Channel=20=C3=BCbergabe=20mit=20einem=20Buffer?= =?UTF-8?q?=20von=2010=20Pl=C3=A4tzen=20f=C3=BCr=20L=C3=A4nderdatens=C3=A4?= =?UTF-8?q?tze?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- eliofile/eliofile.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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) } }