mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-30 21:12:45 +00:00
Update Go, use go tool covdata for coverage files?
This commit is contained in:
parent
5e85a00cb3
commit
6948d16527
8 changed files with 30 additions and 28 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue