MCPcopy Create free account
hub / github.com/apache/answer-plugins / sync

Method sync

search-meilisearch/sync.go:34–57  ·  view source on GitHub ↗

sync data that already exist in Answer to meilisearch

(ctx context.Context)

Source from the content-addressed store, hash-verified

32
33// sync data that already exist in Answer to meilisearch
34func (s *Search) sync(ctx context.Context) {
35 log.Infof("start to sync question data to meilisearch")
36 if s.syncing {
37 log.Warnf("syncing is running, skip")
38 return
39 }
40
41 syncFns := []func(ctx context.Context, page, pageSize int) (answerList []*plugin.SearchContent, err error){
42 s.syncer.GetQuestionsPage,
43 s.syncer.GetAnswersPage,
44 }
45 s.lock.Lock()
46 defer s.lock.Unlock()
47 if s.syncing {
48 log.Warnf("syncing is running, skip")
49 return
50 }
51
52 s.syncing = true
53 for _, fn := range syncFns {
54 s.syncQuestionAndAnswerData(ctx, fn)
55 }
56 s.syncing = false
57}
58
59func (s *Search) syncQuestionAndAnswerData(ctx context.Context,
60 syncFunc func(ctx context.Context, page, pageSize int) (answerList []*plugin.SearchContent, err error)) {

Callers 1

RegisterSyncerMethod · 0.95

Calls 1

Tested by

no test coverage detected