equinox

package module
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 16 Imported by: 1

README

equinox

WikiExampleTodo

Features

  • Riot APIs implemented:
    • Riot Account
    • League of Legends
    • Teamfight Tactics
    • Valorant
    • Legends of Runeterra
  • Data Dragon and Community Dragon - (Incomplete)
  • Rate limit (Internal)
  • Caching with BigCache or Redis
  • Logging with zerolog
  • Exponential backoff

[!NOTE] equinox currently uses the proposed jsonv2, read more about it here.

Check the Wiki for more information about the library.

Example

For a slightly more advanced example, check out lol-match-crawler.

package main

import (
	"fmt"

	"github.com/Kyagara/equinox"
	"github.com/Kyagara/equinox/clients/lol"
)

func main() {
	client, err := equinox.NewClient("RIOT_API_KEY")
	if err != nil {
		fmt.Println("error creating client: ", err)
		return
	}
	// Get this week's champion rotation.
	ctx := context.Background()
	rotation, err := client.LOL.ChampionV3.Rotation(ctx, lol.BR1)
	if err != nil {
		fmt.Println("error retrieving champion rotation: ", err)
		return
	}
	fmt.Printf("%+v\n", rotation)
	// &{FreeChampionIDs:[17 43 56 62 67 79 85 90 133 145 147 157 201 203 245 518]
	// FreeChampionIDsForNewPlayers:[222 254 427 82 131 147 54 17 18 37]
	// MaxNewPlayerLevel:10}
}

Todo

  • Create a rate limit interface
  • Add Redis store for rate limit, using a lua script
  • Update test data and benchmarks
  • Maybe the context usage throughout the project could be improved
  • Maybe add more options to customize the rate limiter
  • More tests for the internal client and rate limit
  • Improve DDragon/CDragon support

Disclaimer

equinox isn't endorsed by Riot Games and doesn't reflect the views or opinions of Riot Games or anyone officially involved in producing or managing Riot Games properties. Riot Games, and all associated properties are trademarks or registered trademarks of Riot Games, Inc.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultConfig added in v0.14.1

func DefaultConfig(key string) (api.EquinoxConfig, error)

Returns the default equinox config with a provided key.

  • Key : The provided Riot API key.
  • HTTPClient : http.Client with a timeout of 15 seconds.
  • Cache : BigCache with an eviction time of 4 minutes.
  • RateLimit : Internal rate limiter with a limit usage factor of 0.99 and interval overhead of 1 second.
  • Logger : api.Logger object with zerolog.WarnLevel. Will log if rate limited or when retrying a request (before waiting).
  • Retry : api.Retry object with a limit of 3 and jitter of 500 milliseconds.

func DefaultLogger added in v1.0.0

func DefaultLogger() api.Logger

Returns the default logger config

  • Level : zerolog.WarnLevel
  • Pretty : false
  • TimeFieldFormat : zerolog.TimeFormatUnix
  • EnableConfigLogging : true
  • EnableTimestamp : true

func DefaultRetry added in v1.0.0

func DefaultRetry() api.Retry

Returns the default retry config

  • MaxRetries : 3
  • Jitter : 500 milliseconds

Types

type Equinox

type Equinox struct {
	Internal *internal.Client
	Cache    *cache.Cache
	DDragon  *ddragon.Client
	CDragon  *cdragon.Client
	Riot     *riot.Client
	LOL      *lol.Client
	TFT      *tft.Client
	VAL      *val.Client
	LOR      *lor.Client
}

func NewClient

func NewClient(key string) (*Equinox, error)

Creates a new equinox client with the default configuration

func NewClientWithConfig added in v0.3.0

func NewClientWithConfig(config api.EquinoxConfig) *Equinox

Creates a new equinox client using a custom configuration.

Directories

Path Synopsis
Package used to share common constants and structs.
Package used to share common constants and structs.
Cache package to provide an interface to interact with cache stores.
Cache package to provide an interface to interact with cache stores.
clients
cdragon
This package is used to interact with Community Dragon endpoints.
This package is used to interact with Community Dragon endpoints.
ddragon
This package is used to interact with Data Dragon endpoints.
This package is used to interact with Data Dragon endpoints.
lol
This package is used to interact with all LOL endpoints.
This package is used to interact with all LOL endpoints.
lor
This package is used to interact with all LOR endpoints.
This package is used to interact with all LOR endpoints.
riot
This package is used to interact with all Riot endpoints.
This package is used to interact with all Riot endpoints.
tft
This package is used to interact with all TFT endpoints.
This package is used to interact with all TFT endpoints.
val
This package is used to interact with all VAL endpoints.
This package is used to interact with all VAL endpoints.
test
integration
This package only contains integration tests and are meant to be run manually.
This package only contains integration tests and are meant to be run manually.

Jump to

Keyboard shortcuts

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