github

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnexpectedNilResponse = errors.New("go-github returned nil response without error")

Functions

This section is empty.

Types

type Client added in v0.7.0

type Client struct {
	// contains filtered or unexported fields
}

func NewClient added in v0.7.0

func NewClient(logger *slog.Logger, cfg *config.Github, transport *Transport, domainMapper *DomainMapper) *Client

func (*Client) CreateIssueComment added in v0.19.0

func (p *Client) CreateIssueComment(ctx context.Context, owner, repo string, number int, body string) error

CreateIssueComment posts a comment on a GitHub issue. Errors are classified via mapError (rate limit, 5xx, transport).

func (*Client) GetIssueLabels added in v0.19.0

func (p *Client) GetIssueLabels(ctx context.Context, owner, repo string, number int) ([]string, error)

GetIssueLabels fetches the labels on a GitHub issue. Returns an empty slice when the issue has no labels. Errors are classified via mapError (rate limit, 5xx, transport).

func (*Client) GetMostUpdatedIssues added in v0.7.0

func (p *Client) GetMostUpdatedIssues(ctx context.Context, request Request) (Response, error)

GetMostUpdatedIssues fetches issues from the given repository, sorted by update time (oldest first).

The client is stateless per repository — owner and repo come from Request. Rate limiting is handled transparently by the underlying http.RoundTripper.

Returns a domain-facing Response that never exposes go-github types. Response.NotModified is true when the server returned 304 (ETag matched).

Errors are classified via mapError: rate limits → RateLimitError (implements apierr.Retryable, WaitHinted, ServicePressure), server errors (5xx) → ServerError (implements apierr.Retryable), transport errors → returned as-is (classified by longrun built-in transport classifier), permanent failures (401, 404, 422) → returned as-is.

func (*Client) GetRepository added in v0.12.0

func (p *Client) GetRepository(ctx context.Context, owner, repo string) (*github.Repository, error)

GetRepository fetches repository metadata from GitHub API. Used by preflight to validate repository existence and accessibility.

func (*Client) HasCommentWithMarker added in v0.19.0

func (p *Client) HasCommentWithMarker(ctx context.Context, owner, repo string, number int, marker string) (bool, error)

HasCommentWithMarker checks whether any comment on the issue contains the given marker string. Used for feedback loop prevention: if autosolve already posted, skip re-processing. Fetches up to 100 comments per page and paginates until found or exhausted. Errors are classified via mapError (rate limit, 5xx, transport).

type Cursor added in v0.13.0

type Cursor struct {
	ETag  string
	Limit int
	Page  int
	Since time.Time
}

Cursor carries pagination and conditional-request state for a single API call. Built by the domain layer from entities.Offset; interpreted by Client.

type DomainMapper added in v0.13.0

type DomainMapper struct{}

func NewDomainMapper added in v0.13.0

func NewDomainMapper() *DomainMapper

func (*DomainMapper) MapIssue added in v0.13.0

func (d *DomainMapper) MapIssue(issue *github.Issue) *entities.Issue

func (*DomainMapper) MapIssues added in v0.13.0

func (d *DomainMapper) MapIssues(issues []*github.Issue) ([]*entities.Issue, error)

type RateLimitError added in v0.13.0

type RateLimitError struct {
	RetryAfter time.Duration
	Err        error
}

RateLimitError is a domain-visible rate limit error. It carries RetryAfter so the caller can sleep precisely until the limit resets. Does NOT depend on go-github — domain imports only this type.

Implements apierr.Retryable, apierr.WaitHinted, apierr.ServicePressure.

func (*RateLimitError) Error added in v0.13.0

func (e *RateLimitError) Error() string

func (*RateLimitError) Retryable added in v0.14.0

func (e *RateLimitError) Retryable() bool

func (*RateLimitError) ServicePressure added in v0.14.0

func (e *RateLimitError) ServicePressure() bool

func (*RateLimitError) Unwrap added in v0.13.0

func (e *RateLimitError) Unwrap() error

func (*RateLimitError) WaitDuration added in v0.14.0

func (e *RateLimitError) WaitDuration() time.Duration

type Request added in v0.13.0

type Request struct {
	Owner      string
	Repository string
	Cursor     Cursor
}

Request identifies the repository and cursor for a GitHub API call.

type Response added in v0.13.0

type Response struct {
	// Issues contains the fetched domain entities. Nil when NotModified is true.
	Issues []*entities.Issue

	// NextCursor is the recommended cursor for the next request.
	// The domain layer converts it to entities.Offset and persists via the topic.
	NextCursor Cursor

	// NotModified is true when the server returned 304 (ETag matched).
	// Issues is nil and NextCursor is unchanged in this case.
	NotModified bool
}

Response is the domain-facing result of a GitHub API call. It isolates the domain from go-github types — *github.Response never leaves this package.

type ServerError added in v0.14.0

type ServerError struct {
	StatusCode int
	Err        error
}

ServerError represents a server-side failure (HTTP 5xx). The server acknowledged the request but failed to process it.

Implements apierr.Retryable.

func (*ServerError) Error added in v0.14.0

func (e *ServerError) Error() string

func (*ServerError) Retryable added in v0.14.0

func (e *ServerError) Retryable() bool

func (*ServerError) Unwrap added in v0.14.0

func (e *ServerError) Unwrap() error

type Transport added in v0.13.0

type Transport struct {
	// contains filtered or unexported fields
}

Transport is an http.RoundTripper that ... TODO: add full responsibility description

func NewTransport added in v0.13.0

func NewTransport(throttler *limit.MinIntervalThrottler) *Transport

func (*Transport) RoundTrip added in v0.13.0

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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