ghclient

package
v0.0.0-...-e9233d5 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: MIT

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckRateLimit

func CheckRateLimit(ctx context.Context, client *github.Client)

CheckRateLimit retrieves the current GitHub API rate limit status and logs it. This is useful for monitoring usage and diagnosing rate limit errors.

- ctx: The context for the API call, allows for cancellation/timeouts. - client: The initialized GitHub client for making API requests.

func NewClient

func NewClient(ctx context.Context) (*github.Client, error)

NewClient initializes and returns a new GitHub API client. It configures authentication (using GITHUB_TOKEN if available) and adds an HTTP cache layer.

- ctx: The context for the client, allows for cancellation. Returns: An initialized *github.Client and an error if setup fails (e.g., cache directory creation).

func PrintRateLimit

func PrintRateLimit(resp *github.Response)

PrintRateLimit logs rate limit information extracted directly from a GitHub API Response. This function is primarily used as a fallback if retrieving the full RateLimit struct fails.

- resp: The *github.Response object from a GitHub API call.

Types

type CachingTransport

type CachingTransport struct {
	Transport http.RoundTripper // The underlying transport, which could be the cache transport or an authenticated transport.
}

CachingTransport wraps an http.RoundTripper to potentially add custom logic, such as logging or metrics, around the transport (including the cache layer).

func (*CachingTransport) RoundTrip

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

RoundTrip executes a single HTTP transaction, passing it to the wrapped Transport. This method satisfies the http.RoundTripper interface.

- req: The HTTP request to execute. Returns: The HTTP response and an error, if any.

Jump to

Keyboard shortcuts

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