Initial
This commit is contained in:
commit
9240e1dfea
7 changed files with 842 additions and 0 deletions
39
rex_model/types.go
Normal file
39
rex_model/types.go
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
package model
|
||||
|
||||
// Recieved from the client
|
||||
type UpdateCheck struct {
|
||||
Addons []string // List of installed addons
|
||||
}
|
||||
|
||||
// A set of addons along with version info
|
||||
type UpdateResponse struct {
|
||||
Addons []AddonData
|
||||
}
|
||||
|
||||
// Holds addon name and information about its latest version.
|
||||
// Used as response type.
|
||||
type AddonData struct {
|
||||
name string
|
||||
latest string
|
||||
}
|
||||
|
||||
func (*AddonData) new(name string, latest string) AddonData {
|
||||
return AddonData{name, latest}
|
||||
}
|
||||
|
||||
// Used as a cache between db
|
||||
type AddonCache interface {
|
||||
check([]AddonData) // Checks list for new versions
|
||||
}
|
||||
|
||||
type AddonDB interface {
|
||||
lookUp(string) AddonData // Looks up the latest version of an addon
|
||||
setLatest(string, string) // Sets the latest version of an addon
|
||||
}
|
||||
|
||||
// The HTTP API gets a request from the client containing a list of installed addons.
|
||||
// This list is passed to the AddonCache which checks the list for new versions.
|
||||
// The AddonCache will check its LRUCache for the latest version of the addon.
|
||||
// If the lookup is a miss, the AddonCache will query the AddonDB for the latest version.
|
||||
// If the AddonDB has a lastChecked time that is older than a certain threshold, it will
|
||||
// query the remote server for the latest version and update the AddonDB.
|
||||
Loading…
Add table
Add a link
Reference in a new issue