Go: add context (#17314)

### Summary

As title.

---------

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
Jin Hai
2026-07-24 16:47:12 +08:00
committed by GitHub
parent 008fa3e10e
commit bdfc3ada41
78 changed files with 1031 additions and 904 deletions

View File

@@ -309,7 +309,7 @@ func (h *Handler) DeleteUser(c *gin.Context) {
return
}
result, err := h.service.DeleteUser(username)
result, err := h.service.DeleteUser(c.Request.Context(), username)
if err != nil {
common.ErrorWithCode(c, common.CodeServerError, err.Error())
return

View File

@@ -494,7 +494,7 @@ type DeleteUserResult struct {
// Returns:
// - *DeleteUserResult
// - error: error message
func (s *Service) DeleteUser(username string) (*DeleteUserResult, error) {
func (s *Service) DeleteUser(ctx context.Context, username string) (*DeleteUserResult, error) {
result := &DeleteUserResult{
Username: username,
DeletedDetails: []string{fmt.Sprintf("Drop user: %s", username)},
@@ -559,7 +559,7 @@ func (s *Service) DeleteUser(username string) (*DeleteUserResult, error) {
if len(kbIDs) > 0 {
// 2. Get document IDs
docIDs, err := s.documentDAO.GetAllDocIDsByKBIDs(kbIDs)
docIDs, err := s.documentDAO.GetAllDocIDsByKBIDs(ctx, tx, kbIDs)
if err != nil {
common.Warn("failed to get document IDs", zap.Error(err))
}