Documentation
¶
Index ¶
Constants ¶
const ( ErrorTypeRateLimit = "rate_limit" ErrorTypeTimeout = "timeout" ErrorTypePermission = "permission" ErrorTypeNotFound = "not_found" ErrorTypeNetwork = "network" ErrorTypeUnknown = "unknown" )
Error type constants for GitHub API error classification
Variables ¶
This section is empty.
Functions ¶
func ClassifyGitHubError ¶ added in v1.1.0
ClassifyGitHubError classifies GitHub API errors for better logging and handling. This works for any GitHub API error (REST, GraphQL, notifications, stars, etc.)
func ConvertAPIURLToWeb ¶ added in v1.1.0
ConvertAPIURLToWeb converts GitHub API URLs to web URLs. Example: https://api.github.com/repos/owner/repo/issues/123 -> https://github.com/owner/repo/issues/123
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the main GitHub API client that wraps REST and GraphQL clients
func NewTestClient ¶ added in v1.1.0
func NewTestClient(restClient RESTClient, graphqlClient GraphQLClient) *Client
NewTestClient creates a client with injected dependencies for testing
func (*Client) FetchNotifications ¶
func (c *Client) FetchNotifications() ([]cache.CacheEntry, error)
FetchNotifications fetches unread GitHub notifications from the REST API. It returns a list of cache entries containing notification details. Only unread notifications are fetched (GitHub API default behavior).
func (*Client) FetchRecentStars ¶ added in v1.1.0
FetchRecentStars fetches recent star events using GraphQL with pagination and concurrent processing. It queries all user-owned repositories and fetches stars that occurred after the 'since' timestamp. Uses a worker pool (6 workers) to fetch stars concurrently while respecting rate limits. Returns stars sorted by StarredAt time (newest first).
func (*Client) GetAuthenticatedUser ¶ added in v1.1.0
GetAuthenticatedUser returns the username of the authenticated user
type GitHubClientInterface ¶ added in v1.1.0
type GitHubClientInterface interface {
FetchNotifications() ([]cache.CacheEntry, error)
FetchRecentStars(since time.Time) ([]cache.StarEvent, error)
GetAuthenticatedUser() (string, error)
TestAuth() error
}
GitHubClientInterface defines the main client interface for testing
type GraphQLClient ¶ added in v1.1.0
type GraphQLClient interface {
Do(query string, variables map[string]interface{}, response interface{}) error
}
GraphQLClient wraps the external GraphQL client for mocking
type RESTClient ¶ added in v1.1.0
RESTClient wraps the external REST client for mocking
type ReposResponse ¶ added in v1.1.0
type ReposResponse struct {
Viewer struct {
Repositories struct {
Nodes []struct {
NameWithOwner string `json:"nameWithOwner"`
} `json:"nodes"`
} `json:"repositories"`
} `json:"viewer"`
}
ReposResponse represents the GraphQL response for fetching repositories
type StarsResponse ¶ added in v1.1.0
type StarsResponse struct {
Repository struct {
Stargazers struct {
Edges []struct {
StarredAt time.Time `json:"starredAt"`
Cursor string `json:"cursor"`
Node struct {
Login string `json:"login"`
} `json:"node"`
} `json:"edges"`
PageInfo struct {
HasNextPage bool `json:"hasNextPage"`
EndCursor string `json:"endCursor"`
} `json:"pageInfo"`
} `json:"stargazers"`
} `json:"repository"`
}
StarsResponse represents the GraphQL response for fetching stargazers