aboutsummaryrefslogtreecommitdiff
path: root/internal/fulltext
diff options
context:
space:
mode:
authorTill Faelligen <2353100+S7evinK@users.noreply.github.com>2023-03-22 14:12:06 +0100
committerTill Faelligen <2353100+S7evinK@users.noreply.github.com>2023-03-22 14:50:21 +0100
commit6948d1652742ae83cf7729f1cfaa0d1ea796b703 (patch)
tree018638a36cff184d792a429e503488da3a983b2a /internal/fulltext
parent5e85a00cb36c3d343cd5b6f6a18435989724a135 (diff)
Update Go, use go tool covdata for coverage files?
Diffstat (limited to 'internal/fulltext')
-rw-r--r--internal/fulltext/bleve.go12
-rw-r--r--internal/fulltext/bleve_test.go2
2 files changed, 8 insertions, 6 deletions
diff --git a/internal/fulltext/bleve.go b/internal/fulltext/bleve.go
index 08cef8a9..dea7c504 100644
--- a/internal/fulltext/bleve.go
+++ b/internal/fulltext/bleve.go
@@ -18,10 +18,11 @@
package fulltext
import (
- "context"
"strings"
"github.com/blevesearch/bleve/v2"
+ "github.com/matrix-org/dendrite/setup/process"
+
// side effect imports to allow all possible languages
_ "github.com/blevesearch/bleve/v2/analysis/lang/ar"
_ "github.com/blevesearch/bleve/v2/analysis/lang/cjk"
@@ -84,17 +85,18 @@ func (i *IndexElement) SetContentType(v string) {
}
// New opens a new/existing fulltext index
-func New(ctx context.Context, cfg config.Fulltext) (fts *Search, err error) {
+func New(processCtx *process.ProcessContext, cfg config.Fulltext) (fts *Search, err error) {
fts = &Search{}
fts.FulltextIndex, err = openIndex(cfg)
if err != nil {
return nil, err
}
go func() {
- // Wait for the context (should be from process.ProcessContext) to be
- // done, indicating that Dendrite is shutting down.
- <-ctx.Done()
+ processCtx.ComponentStarted()
+ // Wait for the processContext to be done, indicating that Dendrite is shutting down.
+ <-processCtx.WaitForShutdown()
_ = fts.Close()
+ processCtx.ComponentFinished()
}()
return fts, nil
}
diff --git a/internal/fulltext/bleve_test.go b/internal/fulltext/bleve_test.go
index 6ce69145..bd8289d5 100644
--- a/internal/fulltext/bleve_test.go
+++ b/internal/fulltext/bleve_test.go
@@ -38,7 +38,7 @@ func mustOpenIndex(t *testing.T, tempDir string) (*fulltext.Search, *process.Pro
cfg.InMemory = false
}
ctx := process.NewProcessContext()
- fts, err := fulltext.New(ctx.Context(), cfg)
+ fts, err := fulltext.New(ctx, cfg)
if err != nil {
t.Fatal("failed to open fulltext index:", err)
}