]> git.lizzy.rs Git - go-anidb.git/blob - anidb.go
anidb: Document that credentials are needed for UDP queries
[go-anidb.git] / anidb.go
1 // Attempt at high level client library for AniDB's APIs
2 package anidb
3
4 import (
5         "time"
6 )
7
8 // Main struct for the client, contains all non-shared state.
9 //
10 // All ObjectByKey methods (AnimeByID, GroupByName, etc) first try to read
11 // from the cache. If the sought object isn't cached, or if the cache is
12 // stale, then the appropriate API is queried.
13 //
14 // Queries that depend on the UDP API can't be used without first authenticating
15 // to the API server. This uses the credentials stored by SetCredentials, or
16 // by a previous Auth() call.
17 type AniDB struct {
18         Timeout time.Duration // Timeout for the various calls (default: 45s)
19
20         udp *udpWrap
21 }
22
23 // Initialises a new AniDB.
24 func NewAniDB() *AniDB {
25         return &AniDB{
26                 Timeout: 45 * time.Second,
27                 udp:     newUDPWrap(),
28         }
29 }