MCPcopy Index your code
hub / github.com/apache/answer / handleOnce

Function handleOnce

internal/service/vector_sync/vector_sync.go:87–115  ·  view source on GitHub ↗
(ctx context.Context, data *data.Data, vectorSearch plugin.VectorSearch,
	action, objectType, objectID string)

Source from the content-addressed store, hash-verified

85}
86
87func handleOnce(ctx context.Context, data *data.Data, vectorSearch plugin.VectorSearch,
88 action, objectType, objectID string) error {
89 if action == ActionDelete {
90 return vectorSearch.DeleteContent(ctx, objectID)
91 }
92 if action != ActionUpsert {
93 return nil
94 }
95
96 var (
97 content *plugin.VectorSearchContent
98 err error
99 )
100 switch objectType {
101 case ObjectTypeQuestion:
102 content, err = vector_search_sync.BuildQuestionContentByID(ctx, data, objectID)
103 case ObjectTypeAnswer:
104 content, err = vector_search_sync.BuildAnswerContentByID(ctx, data, objectID)
105 default:
106 return nil
107 }
108 if err != nil {
109 return err
110 }
111 if content == nil {
112 return vectorSearch.DeleteContent(ctx, objectID)
113 }
114 return vectorSearch.UpdateContent(ctx, content)
115}

Callers 1

handleFunction · 0.85

Calls 4

BuildQuestionContentByIDFunction · 0.92
BuildAnswerContentByIDFunction · 0.92
DeleteContentMethod · 0.65
UpdateContentMethod · 0.65

Tested by

no test coverage detected