Update Go, use go tool covdata for coverage files?

This commit is contained in:
Till Faelligen 2023-03-22 14:12:06 +01:00
parent 5e85a00cb3
commit 6948d16527
No known key found for this signature in database
GPG key ID: ACCDC9606D472758
8 changed files with 30 additions and 28 deletions

View file

@ -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
}

View file

@ -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)
}