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.
- If an API endpoint returns chunked data, irdata will handle the chunk fetching and return a merged object (note, it could be *huge*)
- 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 ¶
- Constants
- type CredsFromTerminal
- type CredsProvider
- type Irdata
- func (i *Irdata) AuthAndSaveProvidedCredsToFile(keyFilename string, authFilename string, authSource CredsProvider) error
- func (i *Irdata) AuthWithCredsFromFile(keyFilename string, authFilename string) error
- func (i *Irdata) AuthWithProvideCreds(authSource CredsProvider) error
- func (i *Irdata) Close()
- func (i *Irdata) DisableDebug()
- 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)
- func (i *Irdata) SetLogLevel(logLevel LogLevel)
- type LogLevel
Constants ¶
const ChunkDataKey = "_chunk_data"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CredsFromTerminal ¶
type CredsFromTerminal struct{}
type CredsProvider ¶
type Irdata ¶
type Irdata struct {
// contains filtered or unexported fields
}
func (*Irdata) AuthAndSaveProvidedCredsToFile ¶ added in v0.4.3
func (i *Irdata) AuthAndSaveProvidedCredsToFile(keyFilename string, authFilename string, authSource CredsProvider) error
AuthAndSaveProvidedCredsToFile calls the provided function for the username and password, verifies auth, and then saves these credentials to authFilename using the key in keyFilename
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) DisableDebug ¶ added in v0.3.0
func (i *Irdata) DisableDebug()
DisableDebug disables debug logging
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 logrus 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 NOTE: If data is fetched this will return the data even if it can't be written to the cache (along with an error)
func (*Irdata) SetLogLevel ¶ added in v0.4.0
SetLogLevel sets the loging level using the logrus module