githubstats

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

README

github-stats-api-go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func NewCache

func NewCache() *Cache

NewCache Create a new cache.

  • @return *Cache - The cache

func (*Cache) Get

func (c *Cache) Get(key string) (GitHubStats, bool)

Get Get the cache entry.

  • @param key string - The key
  • @return GitHubStats, bool - The stats, found

func (*Cache) Set

func (c *Cache) Set(key string, stats GitHubStats, duration time.Duration)

Set Set the cache entry.

  • @param key string - The key
  • @param stats GitHubStats - The stats
  • @param duration time.Duration - The duration
  • @return void

type CacheEntry

type CacheEntry struct {
	Stats      GitHubStats
	Expiration time.Time
}

type Config

type Config struct {
	Path           string         // API path
	Token          string         // GitHub token
	IP             string         // IP address
	Port           string         // Port
	Scheme         string         // HTTP or HTTPS
	CertFile       string         // Certificate file
	KeyFile        string         // Key file
	IncludeOptions IncludeOptions // Include options
	CacheDuration  time.Duration  // Cache duration
	RateLimit      int            // Rate limit
}

type GStats

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

func (*GStats) Connect

func (g *GStats) Connect(config Config) error

Connect initialise le client GitHub avec le token et configure le serveur.

  • @param config Config - The configuration
  • @return error? - The error

func (*GStats) GetGitHubStats

func (g *GStats) GetGitHubStats(username string, opts IncludeOptions) (GitHubStats, error)

GetGitHubStats Get the GitHub stats for a given user according to the specified options.

  • @param username string - The username
  • @param opts IncludeOptions - The options
  • @return GitHubStats, error - The stats, the error

type GitHubStats

type GitHubStats struct {
	Username      string      `json:"username"`
	Followers     int         `json:"followers"`
	Following     int         `json:"following"`
	TotalStars    int         `json:"total_stars"`
	Repositories  []RepoStats `json:"repositories"`
	Organizations []string    `json:"organizations"`
}

type IncludeOptions

type IncludeOptions struct {
	IncludeStars       bool // Include stars
	IncludeFollowers   bool // Include followers
	IncludeFollowing   bool // Include following
	IncludeRepos       bool // Include repositories
	IncludeFirstNRepos int  // Number of repositories to retrieve
	IncludeOrgs        bool // Include organizations
}

type Organizations

type Organizations struct {
	Organizations []string `json:"organizations"`
}

type RateLimiter

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

func NewRateLimiter

func NewRateLimiter(limit int, interval time.Duration) *RateLimiter

NewRateLimiter Create a new rate limiter.

  • @param limit int - The limit
  • @param interval time.Duration - The interval
  • @return *RateLimiter - The rate limiter

func (*RateLimiter) Allow

func (rl *RateLimiter) Allow() bool

Allow Allow a request.

  • @return bool - The result

type RepoStats

type RepoStats struct {
	Name         string         `json:"name"`
	Stars        int            `json:"stars"`
	Forks        int            `json:"forks"`
	OpenIssues   int            `json:"open_issues"`
	Contributors map[string]int `json:"contributors"`
}

Jump to

Keyboard shortcuts

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