refactor: Update function signatures across multiple files to improve readability by adding context parameters and enhancing code structure

This commit is contained in:
wizardchen
2025-11-28 16:17:52 +08:00
parent 135e33eca4
commit eb8bfddfd1
89 changed files with 1453 additions and 522 deletions
+31 -7
View File
@@ -49,7 +49,11 @@ func (s *mcpServiceService) CreateMCPService(ctx context.Context, service *types
}
// GetMCPServiceByID retrieves an MCP service by ID
func (s *mcpServiceService) GetMCPServiceByID(ctx context.Context, tenantID uint64, id string) (*types.MCPService, error) {
func (s *mcpServiceService) GetMCPServiceByID(
ctx context.Context,
tenantID uint64,
id string,
) (*types.MCPService, error) {
service, err := s.mcpServiceRepo.GetByID(ctx, tenantID, id)
if err != nil {
logger.GetLogger(ctx).Errorf("Failed to get MCP service: %v", err)
@@ -80,7 +84,11 @@ func (s *mcpServiceService) ListMCPServices(ctx context.Context, tenantID uint64
}
// ListMCPServicesByIDs retrieves multiple MCP services by IDs
func (s *mcpServiceService) ListMCPServicesByIDs(ctx context.Context, tenantID uint64, ids []string) ([]*types.MCPService, error) {
func (s *mcpServiceService) ListMCPServicesByIDs(
ctx context.Context,
tenantID uint64,
ids []string,
) ([]*types.MCPService, error) {
if len(ids) == 0 {
return []*types.MCPService{}, nil
}
@@ -221,7 +229,11 @@ func (s *mcpServiceService) DeleteMCPService(ctx context.Context, tenantID uint6
}
// TestMCPService tests the connection to an MCP service and returns available tools/resources
func (s *mcpServiceService) TestMCPService(ctx context.Context, tenantID uint64, id string) (*types.MCPTestResult, error) {
func (s *mcpServiceService) TestMCPService(
ctx context.Context,
tenantID uint64,
id string,
) (*types.MCPTestResult, error) {
// Get service
service, err := s.mcpServiceRepo.GetByID(ctx, tenantID, id)
if err != nil {
@@ -280,15 +292,23 @@ func (s *mcpServiceService) TestMCPService(ctx context.Context, tenantID uint64,
}
return &types.MCPTestResult{
Success: true,
Message: fmt.Sprintf("Connected successfully to %s v%s", initResult.ServerInfo.Name, initResult.ServerInfo.Version),
Success: true,
Message: fmt.Sprintf(
"Connected successfully to %s v%s",
initResult.ServerInfo.Name,
initResult.ServerInfo.Version,
),
Tools: tools,
Resources: resources,
}, nil
}
// GetMCPServiceTools retrieves the list of tools from an MCP service
func (s *mcpServiceService) GetMCPServiceTools(ctx context.Context, tenantID uint64, id string) ([]*types.MCPTool, error) {
func (s *mcpServiceService) GetMCPServiceTools(
ctx context.Context,
tenantID uint64,
id string,
) ([]*types.MCPTool, error) {
// Get service
service, err := s.mcpServiceRepo.GetByID(ctx, tenantID, id)
if err != nil {
@@ -314,7 +334,11 @@ func (s *mcpServiceService) GetMCPServiceTools(ctx context.Context, tenantID uin
}
// GetMCPServiceResources retrieves the list of resources from an MCP service
func (s *mcpServiceService) GetMCPServiceResources(ctx context.Context, tenantID uint64, id string) ([]*types.MCPResource, error) {
func (s *mcpServiceService) GetMCPServiceResources(
ctx context.Context,
tenantID uint64,
id string,
) ([]*types.MCPResource, error) {
// Get service
service, err := s.mcpServiceRepo.GetByID(ctx, tenantID, id)
if err != nil {