github

package
v0.0.0-...-f0cbedd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultMaxRetries is the default retry count for GitHub API requests.
	DefaultMaxRetries = 3
	// DefaultInitialBackoff is the first retry delay.
	DefaultInitialBackoff = 2 * time.Second
)

Variables

View Source
var ErrResourceNotFound = errors.New("github resource not found")

ErrResourceNotFound indicates the requested GitHub resource does not exist.

View Source
var ErrUnsupportedResourceType = errors.New("unsupported github resource type")

ErrUnsupportedResourceType indicates the resource type is unknown to the fetcher dispatcher.

Functions

func IsAuthError

func IsAuthError(err error) bool

IsAuthError reports whether an error is an authentication or authorization failure.

func IsRateLimitError

func IsRateLimitError(err error) bool

IsRateLimitError reports whether an error is a GitHub rate limit failure.

func NewStatusError

func NewStatusError(statusCode int, err error, header http.Header) error

NewStatusError builds a classified HTTP status error with any retry metadata from headers.

func StatusCode

func StatusCode(err error) (int, bool)

StatusCode extracts the wrapped HTTP status code when available.

Types

type CommentNode

type CommentNode struct {
	ID        string
	Author    string
	Body      string
	CreatedAt string
	UpdatedAt string
	URL       string
	Replies   []CommentNode
	Reactions ReactionSummary
}

CommentNode represents one comment and its nested replies.

type Config

type Config struct {
	HTTPClient     *http.Client
	Token          string
	RESTBaseURL    string
	GraphQLURL     string
	MaxRetries     int
	InitialBackoff time.Duration
}

Config configures the GitHub fetcher client.

func (Config) WithDefaults

func (c Config) WithDefaults() Config

WithDefaults fills missing optional values with package defaults.

type FetchOptions

type FetchOptions struct {
	IncludeComments bool
}

FetchOptions controls fetch-time behavior.

type Fetcher

type Fetcher interface {
	Fetch(ctx context.Context, ref ResourceRef, opts FetchOptions) (IssueData, error)
}

Fetcher defines the contract for fetching and normalizing one GitHub resource.

func NewFetcher

func NewFetcher(cfg Config) (Fetcher, error)

NewFetcher constructs a fetcher instance.

type IssueData

type IssueData struct {
	Description string
	Timeline    []TimelineEvent
	Reviews     []ReviewData
	Thread      []CommentNode
	Meta        Metadata
	Reactions   ReactionSummary
}

IssueData is the normalized transport payload consumed by other layers.

type Label

type Label struct {
	Name string
}

Label stores minimal label data needed for output rendering.

type Metadata

type Metadata struct {
	Category             string
	MergedAt             string
	AcceptedAnswerAuthor string
	State                string
	Author               string
	CreatedAt            string
	Title                string
	AcceptedAnswerID     string
	Type                 ResourceType
	URL                  string
	UpdatedAt            string
	Labels               []Label
	ReviewCount          int
	Number               int
	IsAnswered           bool
	Merged               bool
}

Metadata stores top-level fields used in front matter and metadata sections.

type ReactionSummary

type ReactionSummary struct {
	PlusOne  int
	MinusOne int
	Laugh    int
	Hooray   int
	Confused int
	Heart    int
	Rocket   int
	Eyes     int
	Total    int
}

ReactionSummary captures aggregate reaction counts on a GitHub entity.

type ResourceRef

type ResourceRef struct {
	Owner  string
	Repo   string
	Type   ResourceType
	URL    string
	Number int
}

ResourceRef is the normalized resource identity extracted from an input URL.

type ResourceType

type ResourceType string

ResourceType identifies the GitHub resource kind represented by a URL.

const (
	// ResourceIssue is the type for GitHub issue URLs.
	ResourceIssue ResourceType = "issue"
	// ResourcePullRequest is the type for GitHub pull request URLs.
	ResourcePullRequest ResourceType = "pull_request"
	// ResourceDiscussion is the type for GitHub discussion URLs.
	ResourceDiscussion ResourceType = "discussion"
)

type ReviewData

type ReviewData struct {
	ID        string
	State     string
	Author    string
	Body      string
	CreatedAt string
	Comments  []CommentNode
	Reactions ReactionSummary
}

ReviewData stores review summary data and review-thread comments.

type TimelineEvent

type TimelineEvent struct {
	EventType string
	Actor     string
	CreatedAt string
	Details   string
}

TimelineEvent represents one normalized timeline event.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL