Documentation ¶
Overview ¶
Package irdata provides simplified access to the [iRacing /data API]
- Authentication is handled internally and credentials can be saved in an encrypted credentials file protected by a secure key file.
- The iRacing /data API returns data in the form of S3 links. This package delivers the S3 results directly handling all the redirection.
- An optional caching layer is provided to minimize direct calls to the /data endpoints themselves as those are rate limited.
[iRacing /data API] https://forums.iracing.com/discussion/15068/general-availability-of-data-api/p1
Index ¶
- func SaveProvidedCredsToFile(keyFilename string, authFilename string, authSource CredsProvider)
- type Chunk
- type CredsFromTerminal
- type CredsProvider
- type Irdata
- func (i *Irdata) AuthWithCredsFromFile(keyFilename string, authFilename string) error
- func (i *Irdata) AuthWithProvideCreds(authSource CredsProvider) error
- func (i *Irdata) Close()
- func (i *Irdata) EnableCache(cacheDir string) error
- func (i *Irdata) EnableDebug()
- func (i *Irdata) Get(uri string) ([]byte, error)
- func (i *Irdata) GetWithCache(uri string, ttl time.Duration) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SaveProvidedCredsToFile ¶
func SaveProvidedCredsToFile(keyFilename string, authFilename string, authSource CredsProvider)
SaveProvidedCredsToFile calls the provided function for the username and password and then saves these credentials to authFilename using the key within the keyFilename
This function will panic out on errors
Types ¶
type CredsFromTerminal ¶
type CredsFromTerminal struct{}
func (CredsFromTerminal) GetCreds ¶
func (CredsFromTerminal) GetCreds() ([]byte, []byte)
CredsFromTerminal can be used with any of the SetCreds* functions and will prompt for iRacing credentials (username and password) from the terminal.
type CredsProvider ¶
type Irdata ¶
type Irdata struct {
// contains filtered or unexported fields
}
func (*Irdata) AuthWithCredsFromFile ¶
AuthWithCredsFromFile loads the username and password from a file at authFilename and encrypted with the key in keyFilename.
func (*Irdata) AuthWithProvideCreds ¶
func (i *Irdata) AuthWithProvideCreds(authSource CredsProvider) error
AuthWithProvideCreds calls the provided function for the username and password
func (*Irdata) Close ¶
func (i *Irdata) Close()
Close Calling Close when done is important when using caching - this will compact the cache.
func (*Irdata) EnableCache ¶
EnableCache enables on the optional caching layer which will use the directory path provided as cacheDir
func (*Irdata) EnableDebug ¶
func (i *Irdata) EnableDebug()
EnableDebug enables debug logging which uses the log module
func (*Irdata) Get ¶
Get returns the result value for the uri provided (e.g. "/data/member/info")
The value returned is a JSON byte array and a potential error.
Get will automatically retry 5 times if iRacing returns 500 errors
func (*Irdata) GetWithCache ¶
GetWithCache will first check the local cache for an unexpired result and will the call Get with the uri provided.
The ttl defines for how long the results should be cached.
You must call EnableCache before calling GetWithCache