Documentation
¶
Index ¶
- type CodeBlock
- type ConcurrencyManager
- type Discussion
- type Handler
- type LanguageInfo
- type ManagerStats
- type Period
- type PlatformInfo
- type RepoSource
- type RepoSummary
- type SearchSummary
- type SourceInfo
- type ToolInfo
- type ToolsManager
- func (tm *ToolsManager) CancelJob(jobID string) bool
- func (tm *ToolsManager) ExecuteWithConcurrency(ctx context.Context, jobID string, fn func() error) error
- func (tm *ToolsManager) GetActiveJobs() []string
- func (tm *ToolsManager) GetHandler() *Handler
- func (tm *ToolsManager) GetStats() ManagerStats
- func (tm *ToolsManager) HealthCheck(ctx context.Context) map[string]interface{}
- func (tm *ToolsManager) WarmupCache(ctx context.Context) error
- type TopicSearchParams
- type TopicSearchResult
- type TopicSearchService
- type TrendingReposParams
- type TrendingReposResult
- type TrendingReposService
- type ValidationError
- type ValidationErrors
- type Validator
- func (v *Validator) GetValidationErrorResponse(err error) map[string]interface{}
- func (v *Validator) SanitizeInput(input string) string
- func (v *Validator) ValidateAndSanitizeQuery(query string) (string, error)
- func (v *Validator) ValidateTopicSearchParams(params TopicSearchParams) error
- func (v *Validator) ValidateTrendingReposParams(params TrendingReposParams) error
- func (v *Validator) ValidateWeeklyNewsParams(params WeeklyNewsParams) error
- type WeeklyNewsParams
- type WeeklyNewsResult
- type WeeklyNewsService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CodeBlock ¶
type CodeBlock struct {
Language string `json:"language"`
Code string `json:"code"`
Context string `json:"context,omitempty"`
}
CodeBlock 代码块
type ConcurrencyManager ¶
type ConcurrencyManager struct {
// contains filtered or unexported fields
}
ConcurrencyManager 并发管理器
type Discussion ¶
type Discussion struct {
ID string `json:"id"`
Title string `json:"title"`
URL string `json:"url"`
Platform string `json:"platform"`
Author string `json:"author"`
Score int `json:"score"`
Replies int `json:"replies"`
CreatedAt time.Time `json:"createdAt"`
Tags []string `json:"tags"`
Content string `json:"content,omitempty"`
CodeBlocks []CodeBlock `json:"codeBlocks,omitempty"`
Relevance float64 `json:"relevance"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
Discussion 讨论信息
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler MCP工具处理器,负责注册和处理所有MCP工具调用
func NewHandler ¶
func NewHandler( cacheManager *cache.CacheManager, collectorMgr *collector.CollectorManager, processor *processor.Processor, formatterFactory *formatter.FormatterFactory, ) *Handler
NewHandler 创建新的MCP工具处理器
type LanguageInfo ¶
type LanguageInfo struct {
Name string `json:"name"`
Count int `json:"count"`
Percentage float64 `json:"percentage"`
TotalStars int `json:"totalStars"`
}
LanguageInfo 编程语言信息
type ManagerStats ¶
type ManagerStats struct {
MaxConcurrency int `json:"maxConcurrency"`
ActiveJobs int `json:"activeJobs"`
AvailableSlots int `json:"availableSlots"`
CacheSize int `json:"cacheSize"`
CacheHitRate float64 `json:"cacheHitRate"`
UpdatedAt time.Time `json:"updatedAt"`
}
ManagerStats 管理器统计信息
type Period ¶
type Period struct {
Start time.Time `json:"start"`
End time.Time `json:"end"`
Days int `json:"days"`
}
Period 时间范围信息
type PlatformInfo ¶
type PlatformInfo struct {
Name string `json:"name"`
Type string `json:"type"`
Count int `json:"count"`
Quality float64 `json:"quality"`
}
PlatformInfo 平台信息
type RepoSource ¶
type RepoSource struct {
Name string `json:"name"`
Count int `json:"count"`
Quality float64 `json:"quality"`
LastSync time.Time `json:"lastSync"`
}
RepoSource 仓库来源信息
type RepoSummary ¶
type RepoSummary struct {
TopLanguages []LanguageInfo `json:"topLanguages"`
CategoryStats map[string]int `json:"categoryStats"`
StarDistribution map[string]int `json:"starDistribution"`
ActivityLevel map[string]int `json:"activityLevel"`
TrendingTopics []string `json:"trendingTopics"`
AverageStars float64 `json:"averageStars"`
TotalStars int `json:"totalStars"`
}
RepoSummary 仓库摘要
type SearchSummary ¶
type SearchSummary struct {
TopicKeywords []string `json:"topicKeywords"`
PopularLanguages []string `json:"popularLanguages"`
TrendingTopics []string `json:"trendingTopics"`
AverageScore float64 `json:"averageScore"`
SearchStats map[string]int `json:"searchStats"`
}
SearchSummary 搜索摘要
type SourceInfo ¶
type SourceInfo struct {
Name string `json:"name"`
Count int `json:"count"`
Type string `json:"type"`
}
SourceInfo 数据源信息
type ToolInfo ¶
type ToolInfo struct {
Name string `json:"name"`
Description string `json:"description"`
Category string `json:"category"`
Parameters []string `json:"parameters"`
Examples []string `json:"examples"`
}
ToolInfo 工具信息
type ToolsManager ¶
type ToolsManager struct {
// contains filtered or unexported fields
}
ToolsManager 工具管理器,提供并发请求处理和缓存优化
func NewToolsManager ¶
func NewToolsManager( cacheManager *cache.CacheManager, collectorMgr *collector.CollectorManager, processor *processor.Processor, formatterFactory *formatter.FormatterFactory, maxConcurrent int, ) *ToolsManager
NewToolsManager 创建工具管理器
func (*ToolsManager) CancelJob ¶
func (tm *ToolsManager) CancelJob(jobID string) bool
CancelJob 取消指定任务
func (*ToolsManager) ExecuteWithConcurrency ¶
func (tm *ToolsManager) ExecuteWithConcurrency(ctx context.Context, jobID string, fn func() error) error
ExecuteWithConcurrency 并发执行工具调用
func (*ToolsManager) GetActiveJobs ¶
func (tm *ToolsManager) GetActiveJobs() []string
GetActiveJobs 获取活跃任务列表
func (*ToolsManager) GetHandler ¶
func (tm *ToolsManager) GetHandler() *Handler
GetHandler 获取MCP工具处理器
func (*ToolsManager) GetStats ¶
func (tm *ToolsManager) GetStats() ManagerStats
GetStats 获取工具管理器统计信息
func (*ToolsManager) HealthCheck ¶
func (tm *ToolsManager) HealthCheck(ctx context.Context) map[string]interface{}
HealthCheck 健康检查
func (*ToolsManager) WarmupCache ¶
func (tm *ToolsManager) WarmupCache(ctx context.Context) error
WarmupCache 预热缓存,为常见查询预加载数据
type TopicSearchParams ¶
type TopicSearchParams struct {
// Query 搜索关键词 (必需)
Query string `json:"query" validate:"required"`
// Language 编程语言过滤 (可选: javascript, typescript, etc.)
Language string `json:"language,omitempty"`
// Platform 平台过滤 (可选: github, stackoverflow, reddit, etc.)
Platform string `json:"platform,omitempty"`
// SortBy 排序方式 (relevance, date, popularity, stars)
SortBy string `json:"sortBy,omitempty"`
// TimeRange 时间范围 (可选: day, week, month, year, all)
TimeRange string `json:"timeRange,omitempty"`
// MaxResults 最大返回结果数 (默认30,最大100)
MaxResults int `json:"maxResults,omitempty"`
// Format 输出格式 (json, markdown, text)
Format string `json:"format,omitempty"`
// IncludeCode 是否包含代码片段 (默认true)
IncludeCode bool `json:"includeCode,omitempty"`
// MinScore 最小相关性分数 (0.0-1.0,默认0.3)
MinScore float64 `json:"minScore,omitempty"`
// SearchType 搜索类型 (discussions, repositories, articles, all)
SearchType string `json:"searchType,omitempty"`
}
TopicSearchParams 主题搜索参数
type TopicSearchResult ¶
type TopicSearchResult struct {
Query string `json:"query"`
Articles []models.Article `json:"articles,omitempty"`
Repositories []models.Repository `json:"repositories,omitempty"`
Discussions []Discussion `json:"discussions,omitempty"`
Summary SearchSummary `json:"summary"`
SearchTime time.Time `json:"searchTime"`
TotalResults int `json:"totalResults"`
Sources []PlatformInfo `json:"sources"`
}
TopicSearchResult 主题搜索结果
type TopicSearchService ¶
type TopicSearchService struct {
// contains filtered or unexported fields
}
TopicSearchService 主题搜索服务
func NewTopicSearchService ¶
func NewTopicSearchService( cacheManager *cache.CacheManager, collectorMgr *collector.CollectorManager, processor *processor.Processor, formatterFactory *formatter.FormatterFactory, ) *TopicSearchService
NewTopicSearchService 创建主题搜索服务
func (*TopicSearchService) FormatResult ¶
func (t *TopicSearchService) FormatResult(result *TopicSearchResult, format string) (string, error)
FormatResult 格式化结果输出
func (*TopicSearchService) SearchFrontendTopic ¶
func (t *TopicSearchService) SearchFrontendTopic(ctx context.Context, params TopicSearchParams) (*TopicSearchResult, error)
SearchFrontendTopic 搜索前端相关主题和讨论
type TrendingReposParams ¶
type TrendingReposParams struct {
// Language 编程语言过滤 (可选: javascript, typescript, python, etc.)
Language string `json:"language,omitempty"`
// TimeRange 时间范围 (daily, weekly, monthly)
TimeRange string `json:"timeRange,omitempty"`
// MinStars 最小星标数 (默认10)
MinStars int `json:"minStars,omitempty"`
// MaxResults 最大返回结果数 (默认30,最大100)
MaxResults int `json:"maxResults,omitempty"`
// Category 仓库分类 (可选: framework, library, tool, example)
Category string `json:"category,omitempty"`
// IncludeForks 是否包含Fork仓库 (默认false)
IncludeForks bool `json:"includeForks,omitempty"`
// SortBy 排序方式 (stars, forks, updated, trending)
SortBy string `json:"sortBy,omitempty"`
// Format 输出格式 (json, markdown, text)
Format string `json:"format,omitempty"`
// IncludeDescription 是否包含详细描述 (默认true)
IncludeDescription bool `json:"includeDescription,omitempty"`
// FrontendOnly 是否只返回前端相关仓库 (默认true)
FrontendOnly bool `json:"frontendOnly,omitempty"`
}
TrendingReposParams 热门仓库参数
type TrendingReposResult ¶
type TrendingReposResult struct {
Repositories []models.Repository `json:"repositories"`
Summary RepoSummary `json:"summary"`
TimeRange string `json:"timeRange"`
Language string `json:"language,omitempty"`
TotalCount int `json:"totalCount"`
FilterCount int `json:"filterCount"`
UpdatedAt time.Time `json:"updatedAt"`
Sources []RepoSource `json:"sources"`
}
TrendingReposResult 热门仓库结果
type TrendingReposService ¶
type TrendingReposService struct {
// contains filtered or unexported fields
}
TrendingReposService 热门仓库服务
func NewTrendingReposService ¶
func NewTrendingReposService( cacheManager *cache.CacheManager, collectorMgr *collector.CollectorManager, processor *processor.Processor, formatterFactory *formatter.FormatterFactory, ) *TrendingReposService
NewTrendingReposService 创建热门仓库服务
func (*TrendingReposService) FormatResult ¶
func (t *TrendingReposService) FormatResult(result *TrendingReposResult, format string) (string, error)
FormatResult 格式化结果输出
func (*TrendingReposService) GetTrendingRepositories ¶
func (t *TrendingReposService) GetTrendingRepositories(ctx context.Context, params TrendingReposParams) (*TrendingReposResult, error)
GetTrendingRepositories 获取GitHub热门前端仓库
type ValidationError ¶
type ValidationError struct {
Field string `json:"field"`
Value string `json:"value"`
Message string `json:"message"`
Code string `json:"code"`
}
ValidationError 验证错误,包含详细的错误信息
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator 参数验证器,提供统一的参数验证和错误处理
func (*Validator) GetValidationErrorResponse ¶
GetValidationErrorResponse 获取格式化的验证错误响应
func (*Validator) SanitizeInput ¶
SanitizeInput 清理输入,防止XSS和注入攻击
func (*Validator) ValidateAndSanitizeQuery ¶
ValidateAndSanitizeQuery 验证并清理查询字符串
func (*Validator) ValidateTopicSearchParams ¶
func (v *Validator) ValidateTopicSearchParams(params TopicSearchParams) error
ValidateTopicSearchParams 验证主题搜索参数
func (*Validator) ValidateTrendingReposParams ¶
func (v *Validator) ValidateTrendingReposParams(params TrendingReposParams) error
ValidateTrendingReposParams 验证热门仓库参数
func (*Validator) ValidateWeeklyNewsParams ¶
func (v *Validator) ValidateWeeklyNewsParams(params WeeklyNewsParams) error
ValidateWeeklyNewsParams 验证周报新闻参数
type WeeklyNewsParams ¶
type WeeklyNewsParams struct {
// StartDate 开始日期 (可选,默认为7天前)
StartDate string `json:"startDate,omitempty"`
// EndDate 结束日期 (可选,默认为今天)
EndDate string `json:"endDate,omitempty"`
// Category 新闻分类过滤 (可选: react, vue, angular, nodejs, typescript, etc.)
Category string `json:"category,omitempty"`
// MinQuality 最小质量分数 (0.0-1.0,默认0.5)
MinQuality float64 `json:"minQuality,omitempty"`
// MaxResults 最大返回结果数 (默认50,最大200)
MaxResults int `json:"maxResults,omitempty"`
// Format 输出格式 (json, markdown, text)
Format string `json:"format,omitempty"`
// IncludeContent 是否包含完整内容 (默认false,只返回摘要)
IncludeContent bool `json:"includeContent,omitempty"`
// SortBy 排序方式 (relevance, quality, date, title)
SortBy string `json:"sortBy,omitempty"`
// Sources 指定的数据源 (可选,多个用逗号分隔)
Sources string `json:"sources,omitempty"`
}
WeeklyNewsParams 周报新闻参数
type WeeklyNewsResult ¶
type WeeklyNewsResult struct {
Articles []models.Article `json:"articles"`
Summary string `json:"summary"`
Period Period `json:"period"`
TotalCount int `json:"totalCount"`
FilterCount int `json:"filterCount"`
Sources []SourceInfo `json:"sources"`
}
WeeklyNewsResult 周报新闻结果
type WeeklyNewsService ¶
type WeeklyNewsService struct {
// contains filtered or unexported fields
}
WeeklyNewsService 周报新闻服务
func NewWeeklyNewsService ¶
func NewWeeklyNewsService( cacheManager *cache.CacheManager, collectorMgr *collector.CollectorManager, processor *processor.Processor, formatterFactory *formatter.FormatterFactory, ) *WeeklyNewsService
NewWeeklyNewsService 创建周报新闻服务
func (*WeeklyNewsService) FormatResult ¶
func (w *WeeklyNewsService) FormatResult(result *WeeklyNewsResult, format string) (string, error)
FormatResult 格式化结果输出
func (*WeeklyNewsService) GetWeeklyFrontendNews ¶
func (w *WeeklyNewsService) GetWeeklyFrontendNews(ctx context.Context, params WeeklyNewsParams) (*WeeklyNewsResult, error)
GetWeeklyFrontendNews 获取前端开发周报新闻