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

Function handle

internal/service/vector_sync/vector_sync.go:59–85  ·  view source on GitHub ↗
(ctx context.Context, data *data.Data, msg *Task)

Source from the content-addressed store, hash-verified

57}
58
59func handle(ctx context.Context, data *data.Data, msg *Task) error {
60 if msg == nil || msg.ObjectID == "" {
61 return nil
62 }
63
64 var vectorSearch plugin.VectorSearch
65 _ = plugin.CallVectorSearch(func(vs plugin.VectorSearch) error {
66 vectorSearch = vs
67 return nil
68 })
69 if vectorSearch == nil {
70 return nil
71 }
72
73 objectID := uid.DeShortID(msg.ObjectID)
74 var lastErr error
75 for attempt := 1; attempt <= maxRetry; attempt++ {
76 err := handleOnce(ctx, data, vectorSearch, msg.Action, msg.ObjectType, objectID)
77 if err == nil {
78 return nil
79 }
80 lastErr = err
81 log.Warnf("vector sync failed: action=%s object_type=%s object_id=%s attempt=%d err=%v",
82 msg.Action, msg.ObjectType, objectID, attempt, err)
83 }
84 return lastErr
85}
86
87func handleOnce(ctx context.Context, data *data.Data, vectorSearch plugin.VectorSearch,
88 action, objectType, objectID string) error {

Callers 1

NewServiceFunction · 0.70

Calls 2

DeShortIDFunction · 0.92
handleOnceFunction · 0.85

Tested by

no test coverage detected