github

package
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const GraphQLURL = "https://api.github.com/graphql"

Variables

View Source
var ErrAccessBlocked = errors.New("repository access blocked")
View Source
var ErrNotFound = errors.New("not found on GitHub")
View Source
var ErrTokenNotAvailable = errors.New("all github tokens are not available")
View Source
var ErrTooManyRequests = errors.New("too many requests")

Functions

This section is empty.

Types

type Client

type Client struct {
	TokenPool *TokenPool
}

func NewClient

func NewClient(tokenPool *TokenPool) *Client

func (*Client) GetDeveloper

func (ghClient *Client) GetDeveloper(ctx context.Context, username string) (model.Developer, error)

func (*Client) GetIssues added in v0.10.0

func (ghClient *Client) GetIssues(
	ctx context.Context,
	owner, repo string,
	cursor *string,
	start, end *time.Time) ([]Issue, *string, error)

func (*Client) GetLastCommit added in v0.13.0

func (ghClient *Client) GetLastCommit(ctx context.Context, fullName string) (*time.Time, *time.Time, error)

func (*Client) GetMergedPrs added in v0.10.0

func (ghClient *Client) GetMergedPrs(
	ctx context.Context,
	owner,
	repo string,
	cursor *string, start, end *time.Time) ([]Pr, *string, error)

func (*Client) GetRepository

func (ghClient *Client) GetRepository(ctx context.Context, fullName string) (model.GhRepository, error)

func (*Client) GetRepositoryForks added in v0.10.0

func (ghClient *Client) GetRepositoryForks(
	ctx context.Context,
	owner, repo string,
	cursor *string,
	start *time.Time,
	end *time.Time) ([]Fork, *string, error)

func (*Client) GetRepositoryStars added in v0.10.0

func (ghClient *Client) GetRepositoryStars(
	ctx context.Context,
	owner, repo string,
	cursor *string,
	start *time.Time,
	end *time.Time) ([]Stargazer, *string, error)

type Commit added in v0.13.0

type Commit struct {
	Author struct {
		Name  string `json:"name"`
		Email string `json:"email"`
		Date  string `json:"date"`
	} `json:"author"`
}

type CommitResponse added in v0.13.0

type CommitResponse struct {
	Sha    string `json:"sha"`
	Commit Commit `json:"commit"`
	Author struct {
		UserType string `json:"type"`
	}
}

type Fork added in v0.10.0

type Fork struct {
	CreatedAt time.Time
	Login     string
}

type GraphQLResponse added in v0.10.0

type GraphQLResponse struct {
	Data struct {
		Repository struct {
			Stargazers struct {
				Edges []struct {
					StarredAt string `json:"starredAt"`
					Node      struct {
						Login string `json:"login"`
					} `json:"node"`
				} `json:"edges"`
				PageInfo struct {
					EndCursor   string `json:"endCursor"`
					HasNextPage bool   `json:"hasNextPage"`
				} `json:"pageInfo"`
			} `json:"stargazers"`
			Issues struct {
				Edges []struct {
					Node struct {
						Number    int    `json:"number"`
						Title     string `json:"title"`
						Closed    bool   `json:"closed"`
						ClosedAt  string `json:"closedAt"`
						CreatedAt string `json:"createdAt"`
						UpdatedAt string `json:"updatedAt"`
						Author    struct {
							Login string `json:"login"`
						} `json:"author"`
						URL string `json:"url"`
					} `json:"node"`
				} `json:"edges"`
				PageInfo struct {
					EndCursor   string `json:"endCursor"`
					HasNextPage bool   `json:"hasNextPage"`
				} `json:"pageInfo"`
			} `json:"issues"`
			PullRequests struct {
				Edges []struct {
					Node struct {
						Number   int    `json:"number"`
						Title    string `json:"title"`
						MergedAt string `json:"mergedAt"`
						Author   struct {
							Login string `json:"login"`
						} `json:"author"`
						URL string `json:"url"`
					} `json:"node"`
				} `json:"edges"`
				PageInfo struct {
					EndCursor   string `json:"endCursor"`
					HasNextPage bool   `json:"hasNextPage"`
				} `json:"pageInfo"`
			} `json:"pullRequests"`
			Forks struct {
				Edges []struct {
					Node struct {
						Name  string `json:"name"`
						Owner struct {
							Login string `json:"login"`
						} `json:"owner"`
						CreatedAt string `json:"createdAt"`
					} `json:"node"`
				} `json:"edges"`
				PageInfo struct {
					EndCursor   string `json:"endCursor"`
					HasNextPage bool   `json:"hasNextPage"`
				} `json:"pageInfo"`
			} `json:"forks"`
		} `json:"repository"`
	} `json:"data"`
}

type Issue added in v0.10.0

type Issue struct {
	Title     string
	Number    int
	Closed    bool
	ClosedAt  time.Time
	CreatedAt time.Time
}

type Option added in v0.10.0

type Option func(tp *TokenPool)

func WithAllowEmptytoken added in v0.10.0

func WithAllowEmptytoken(allow bool) Option

type Pr added in v0.10.0

type Pr struct {
	Number   int
	Title    string
	MergedAt time.Time
}

type Stargazer added in v0.10.0

type Stargazer struct {
	StarredAt time.Time
	Login     string
}

type SyncHandler added in v0.6.3

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

func NewSyncHandler added in v0.6.3

func NewSyncHandler(repositoryRepo *model.GhRepositoryRepo, developerRepo *model.DeveloperRepo, client *Client) *SyncHandler

func (*SyncHandler) Handle added in v0.6.3

func (s *SyncHandler) Handle(ctx context.Context, action string, opts ...any) error

type TokenPool added in v0.10.0

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

func NewTokenPool added in v0.10.0

func NewTokenPool(tokens []string, opts ...Option) *TokenPool

func (*TokenPool) Debug added in v0.10.0

func (tp *TokenPool) Debug()

func (*TokenPool) EarliestReset added in v0.10.0

func (tp *TokenPool) EarliestReset() time.Time

func (*TokenPool) GetToken added in v0.10.0

func (tp *TokenPool) GetToken() (string, error)

func (*TokenPool) Update added in v0.10.0

func (tp *TokenPool) Update(token string, remaining int, resetAt time.Time)

Jump to

Keyboard shortcuts

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