diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-05-21 14:44:33 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2023-05-21 14:44:33 +0200 |
| commit | d4dbb47ac776471eb8a9f91a97da40b9b6621a74 (patch) | |
| tree | ea6dc9824b3bc821d6618fe41472050277f6d25b /main.go | |
| parent | f638d3975225b895e7b0a8fb79c6c6de288a732a (diff) | |
| download | WRMS-d4dbb47ac776471eb8a9f91a97da40b9b6621a74.tar.gz WRMS-d4dbb47ac776471eb8a9f91a97da40b9b6621a74.zip | |
paralyze searching
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -9,6 +9,7 @@ import ( "io/ioutil" "net/http" "strings" + "time" "muhq.space/go/wrms/llog" @@ -36,7 +37,16 @@ func searchHandler(w http.ResponseWriter, r *http.Request) { llog.Debug("Searching for %s", pattern) - results := wrms.Player.Search(pattern) + start := time.Now() + resultsChan := wrms.Player.Search(pattern) + results := []Song{} + + for result := range resultsChan { + results = append(results, result...) + } + + llog.Debug("searching for %s took %v", pattern, time.Since(start)) + data, err := json.Marshal(Event{"search", results}) if err != nil { llog.Error("Encoding the search result failed with %s", err) |
