Documentation ¶
Index ¶
- func DisableMirror(r *database.Redis, id int) error
- func EnableMirror(r *database.Redis, id int) error
- func MarkMirrorDown(r *database.Redis, id int, reason string) error
- func MarkMirrorUp(r *database.Redis, id int) error
- func SetMirrorEnabled(r *database.Redis, id int, state bool) error
- func SetMirrorState(r *database.Redis, id int, state bool, reason string) error
- type ByComputedScore
- type ByExcludeReason
- type ByRank
- type Cache
- func (c *Cache) Clear()
- func (c *Cache) GetFileInfo(path string) (f filesystem.FileInfo, err error)
- func (c *Cache) GetMirror(id int) (mirror Mirror, err error)
- func (c *Cache) GetMirrorInvalidationEvent() <-chan string
- func (c *Cache) GetMirrors(path string, clientInfo network.GeoIPRecord) (mirrors []Mirror, err error)
- type Item
- type LRUCache
- func (lru *LRUCache) Clear()
- func (lru *LRUCache) Delete(key string) bool
- func (lru *LRUCache) Get(key string) (v Value, ok bool)
- func (lru *LRUCache) Items() []Item
- func (lru *LRUCache) Keys() []string
- func (lru *LRUCache) Set(key string, value Value)
- func (lru *LRUCache) SetCapacity(capacity uint64)
- func (lru *LRUCache) SetIfAbsent(key string, value Value)
- func (lru *LRUCache) Stats() (length, size, capacity uint64, oldest time.Time)
- func (lru *LRUCache) StatsJSON() string
- type Mirror
- type Mirrors
- type Redirects
- type Results
- type Time
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DisableMirror ¶
DisableMirror disables the given mirror
func EnableMirror ¶
EnableMirror enables the given mirror
func MarkMirrorDown ¶
MarkMirrorDown marks the given mirror as down
func MarkMirrorUp ¶
MarkMirrorUp marks the given mirror as up
func SetMirrorEnabled ¶
SetMirrorEnabled marks a mirror as enabled or disabled
Types ¶
type ByComputedScore ¶
type ByComputedScore struct {
Mirrors
}
ByComputedScore is used to sort a slice of Mirror by their score
func (ByComputedScore) Less ¶
func (b ByComputedScore) Less(i, j int) bool
Less compares two mirrors based on their score
type ByExcludeReason ¶
type ByExcludeReason struct {
Mirrors
}
ByExcludeReason is used to sort a slice of Mirror alphabetically by their exclude reason
func (ByExcludeReason) Less ¶
func (b ByExcludeReason) Less(i, j int) bool
Less compares two mirrors based on their exclude reason
type ByRank ¶
type ByRank struct { Mirrors ClientInfo network.GeoIPRecord }
ByRank is used to sort a slice of Mirror by their rank
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache implements a local caching mechanism of type LRU for content available in the redis database that is automatically invalidated if the object is updated in Redis.
func (*Cache) GetFileInfo ¶
func (c *Cache) GetFileInfo(path string) (f filesystem.FileInfo, err error)
GetFileInfo returns file information for a given file either from the cache or directly from the database if the object is not yet stored in the cache.
func (*Cache) GetMirror ¶
GetMirror returns all information about a given mirror either from the cache or directly from the database if the object is not yet stored in the cache.
func (*Cache) GetMirrorInvalidationEvent ¶
GetMirrorInvalidationEvent returns a channel that contains ID of mirrors that have just been invalidated. This function is supposed to have only ONE reader and is made to avoid a race for MIRROR_UPDATE events between a mirror invalidation and a mirror being fetched from the cache.
func (*Cache) GetMirrors ¶
func (c *Cache) GetMirrors(path string, clientInfo network.GeoIPRecord) (mirrors []Mirror, err error)
GetMirrors returns all the mirrors serving a given file either from the cache or directly from the database if the object is not yet stored in the cache.
type LRUCache ¶
type LRUCache struct {
// contains filtered or unexported fields
}
LRUCache is the internal structure of the cache
func NewLRUCache ¶
NewLRUCache return a new instance of the cache
func (*LRUCache) SetCapacity ¶
SetCapacity sets the capacity of the cache
func (*LRUCache) SetIfAbsent ¶
SetIfAbsent sets a key into the cache only if it doesn't exist yet
type Mirror ¶
type Mirror struct { ID int `redis:"ID" yaml:"-"` Name string `redis:"name" yaml:"Name"` HttpURL string `redis:"http" yaml:"HttpURL"` RsyncURL string `redis:"rsync" yaml:"RsyncURL"` FtpURL string `redis:"ftp" yaml:"FtpURL"` SponsorName string `redis:"sponsorName" yaml:"SponsorName"` SponsorURL string `redis:"sponsorURL" yaml:"SponsorURL"` SponsorLogoURL string `redis:"sponsorLogo" yaml:"SponsorLogoURL"` AdminName string `redis:"adminName" yaml:"AdminName"` AdminEmail string `redis:"adminEmail" yaml:"AdminEmail"` CustomData string `redis:"customData" yaml:"CustomData"` ContinentOnly bool `redis:"continentOnly" yaml:"ContinentOnly"` CountryOnly bool `redis:"countryOnly" yaml:"CountryOnly"` ASOnly bool `redis:"asOnly" yaml:"ASOnly"` Score int `redis:"score" yaml:"Score"` Latitude float32 `redis:"latitude" yaml:"Latitude"` Longitude float32 `redis:"longitude" yaml:"Longitude"` ContinentCode string `redis:"continentCode" yaml:"ContinentCode"` CountryCodes string `redis:"countryCodes" yaml:"CountryCodes"` ExcludedCountryCodes string `redis:"excludedCountryCodes" yaml:"ExcludedCountryCodes"` Asnum uint `redis:"asnum" yaml:"ASNum"` Comment string `redis:"comment" yaml:"-"` Enabled bool `redis:"enabled" yaml:"Enabled"` Up bool `redis:"up" json:"-" yaml:"-"` ExcludeReason string `redis:"excludeReason" json:",omitempty" yaml:"-"` StateSince Time `redis:"stateSince" json:",omitempty" yaml:"-"` AllowRedirects Redirects `redis:"allowredirects" json:",omitempty" yaml:"AllowRedirects"` Distance float32 `redis:"-" yaml:"-"` CountryFields []string `redis:"-" json:"-" yaml:"-"` ExcludedCountryFields []string `redis:"-" json:"-" yaml:"-"` Filepath string `redis:"-" json:"-" yaml:"-"` Weight float32 `redis:"-" json:"-" yaml:"-"` ComputedScore int `redis:"-" yaml:"-"` LastSync Time `redis:"lastSync" yaml:"-"` LastSuccessfulSync Time `redis:"lastSuccessfulSync" yaml:"-"` LastModTime Time `redis:"lastModTime" yaml:"-"` FileInfo *filesystem.FileInfo `redis:"-" json:"-" yaml:"-"` // Details of the requested file on this specific mirror }
Mirror is the structure representing all the information about a mirror
type Redirects ¶
type Redirects int
Redirects is handling the per-mirror authorization of HTTP redirects
func (Redirects) MarshalYAML ¶
MarshalYAML converts internal values to YAML
func (*Redirects) UnmarshalYAML ¶
UnmarshalYAML converts YAML to internal values
type Results ¶
type Results struct { FileInfo filesystem.FileInfo IP string ClientInfo network.GeoIPRecord MirrorList Mirrors ExcludedList Mirrors `json:",omitempty"` Fallback bool `json:",omitempty"` LocalJSPath string }
Results is the resulting struct of a request and is used by the renderers to generate the final page.