Documentation
¶
Index ¶
- Variables
- type API
- type APIIdent
- type CacheEntry
- type Request
- func (r *Request) ApplyCache(c *CacheEntry)
- func (r *Request) ApplyResponse(resp *napping.Response)
- func (r *Request) CacheRead() error
- func (r *Request) CacheWrite(data []byte) (err error)
- func (r *Request) Do() (err error)
- func (r *Request) Error(err error)
- func (r *Request) Lock() error
- func (r *Request) LogStatus()
- func (r *Request) Marshal() ([]byte, error)
- func (r *Request) MarshalCache() ([]byte, error)
- func (r *Request) Prepare() (err error)
- func (r *Request) Reset()
- func (r *Request) Size(size uint64)
- func (r *Request) String() string
- func (r *Request) Unlock() error
- func (r *Request) Unmarshal(b *bytes.Buffer) error
- func (r *Request) UnmarshalCache(b *bytes.Buffer) (*CacheEntry, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( TMDBAPI = &API{ Ident: TMDBIdent, Endpoint: "https://api.themoviedb.org/3", RetriesLeft: 3, RateLimiter: util.NewRateLimiter(50, 1*time.Second, 50), } TraktAPI = &API{ Ident: TraktIdent, Endpoint: "https://api.trakt.tv", RetriesLeft: 3, RateLimiter: util.NewRateLimiter(100, 10*time.Second, 25), } // SimklAPI allows 10 GET/s and 1 POST/s and wants sequential requests, so stay at 1 request per second. SimklAPI = &API{ Ident: SimklIdent, Endpoint: "https://api.simkl.com", RetriesLeft: 3, RateLimiter: util.NewRateLimiter(1, 1*time.Second, 1), } // MDBListAPI allows 1000 reads and 300 writes per 5 minutes; the daily quota is the real limit. MDBListAPI = &API{ Ident: MDBListIdent, Endpoint: "https://api.mdblist.com", RetriesLeft: 3, RateLimiter: util.NewRateLimiter(60, 1*time.Minute, 2), } // ScrobAPI is a self-hosted server: requests carry the full URL from settings, so there is no endpoint. ScrobAPI = &API{ Ident: ScrobIdent, RetriesLeft: 3, RateLimiter: util.NewRateLimiter(10, 1*time.Second, 2), } FanartAPI = &API{ Ident: FanArtIdent, Endpoint: "http://webservice.fanart.tv/v3", RetriesLeft: 3, RateLimiter: util.NewRateLimiter(100, 10*time.Second, 25), } OpenSubtitlesAPI = &API{ Ident: OpenSubtitlesIdent, Endpoint: "https://api.opensubtitles.com/api/v1", RetriesLeft: 3, RateLimiter: util.NewRateLimiter(100, 10*time.Second, 25), } )
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct {
Ident APIIdent
RateLimiter *util.RateLimiter
Endpoint string
RetriesLeft int
}
func (*API) GetSession ¶
type CacheEntry ¶
type CacheEntry struct {
Header map[string][]string `json:"header"`
Body []byte `json:"body"`
// Result is msgpack-encoded Result, stored instead of Body when Result type has generated bindings
Result []byte `json:"result"`
Status string `json:"status"`
StatusCode int `json:"statuscode"`
}
func (*CacheEntry) MarshalMsg ¶ added in v0.1.115
func (z *CacheEntry) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*CacheEntry) Msgsize ¶ added in v0.1.115
func (z *CacheEntry) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*CacheEntry) UnmarshalMsg ¶ added in v0.1.115
func (z *CacheEntry) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type Request ¶
type Request struct {
trace.Tracer
API *API
Method string
URL string
Params url.Values `msg:"-"`
Header http.Header `msg:"-"`
Payload *bytes.Buffer
Description string
Retry int
RetryBackoff time.Duration
ResponseError error
ResponseStatus string
ResponseStatusCode int
ResponseHeader http.Header
ResponseBody *bytes.Buffer
ResponseSize uint64
ResponseIgnore []int
Result any
Cache bool
CacheExpire time.Duration
CacheForceExpire bool
CacheKey string
// contains filtered or unexported fields
}
func (*Request) ApplyCache ¶
func (r *Request) ApplyCache(c *CacheEntry)
func (*Request) ApplyResponse ¶
func (*Request) CacheWrite ¶
func (*Request) MarshalCache ¶
func (*Request) UnmarshalCache ¶
func (r *Request) UnmarshalCache(b *bytes.Buffer) (*CacheEntry, error)
Click to show internal directories.
Click to hide internal directories.