githubapi

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientOptions added in v0.2.0

type ClientOptions struct {
	// Delay is the minimum interval between requests. Zero disables pacing.
	Delay time.Duration
	// MaxWait caps a single rate-limit wait. Zero uses the package default.
	MaxWait time.Duration
	// Notify, when set, is called before each wait so a caller can show it.
	Notify func(ratelimit.Wait)
}

ClientOptions tunes the rate limiting applied to every API request.

type NamedRateLimit added in v0.2.0

type NamedRateLimit struct {
	Name string
	RateLimit
}

NamedRateLimit pairs a resource with its name for ordered rendering.

type RESTClient

type RESTClient interface {
	Get(path string, response interface{}) error
}

type RateLimit added in v0.2.0

type RateLimit struct {
	Limit     int   `json:"limit"`
	Used      int   `json:"used"`
	Remaining int   `json:"remaining"`
	Reset     int64 `json:"reset"`
}

RateLimit is one resource's budget as GitHub reports it.

func (RateLimit) ResetAt added in v0.2.0

func (l RateLimit) ResetAt() time.Time

ResetAt is when the budget refills.

type RateLimits added in v0.2.0

type RateLimits struct {
	Resources map[string]RateLimit `json:"resources"`
}

RateLimits is the whole rate_limit payload.

func (RateLimits) Ordered added in v0.2.0

func (l RateLimits) Ordered() []NamedRateLimit

Ordered lists core first, because it is the budget a sync spends, then the remaining resources alphabetically. Absent resources are simply not listed.

type Source

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

func NewAuthenticatedSource

func NewAuthenticatedSource(host string, options ClientOptions) (*Source, *ratelimit.Transport, string, string, error)

NewAuthenticatedSource builds a source whose transport honours GitHub's rate limits. The transport is returned so a caller can read the current budget.

func NewSource

func NewSource(client RESTClient) *Source

func (*Source) ListRepositories

func (s *Source) ListRepositories(ctx context.Context, organization string) ([]mirror.Repository, error)

func (*Source) RateLimits added in v0.2.0

func (s *Source) RateLimits(ctx context.Context) (RateLimits, error)

RateLimits reads the authenticated account's remaining budget. The call does not itself consume the core budget.

func (*Source) RepositoryCount added in v0.2.0

func (s *Source) RepositoryCount(ctx context.Context, organization string) (int, error)

RepositoryCount reports how many repositories an organization holds, which is what turns a remaining budget into an answer about a planned sync.

Jump to

Keyboard shortcuts

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