36 lines
1.5 KiB
Go
36 lines
1.5 KiB
Go
package connector
|
|
|
|
import (
|
|
model "galaxy/model/client"
|
|
"galaxy/model/report"
|
|
)
|
|
|
|
// Connector is a main interface to provide connectivity with app's server.
|
|
type Connector interface {
|
|
UIConnector
|
|
|
|
// CheckConnection is called asynchronously every 5 seconds and tests is connection available with a specific backend server endpoint.
|
|
// There is guaranteed backoff 5s -> 15s -> 30s -> 60s when no connection is available.
|
|
CheckConnection() bool
|
|
|
|
// CheckVersion is called asynchronously every 30 minutes and receives from backend server information about currently available app versions.
|
|
CheckVersion() ([]VersionInfo, error)
|
|
|
|
// DownloadVersion asynchronously retrieves from a specific string URL a binary artifact from backend server.
|
|
DownloadVersion(string) ([]byte, error)
|
|
}
|
|
|
|
// UIConnector contains only funcs are needed for the client app to be functional.
|
|
type UIConnector interface {
|
|
// FetchReport asynchronously requests from backend server a [report.Report] for a given [model.GameID] and turn number.
|
|
// Passed callback func will will accept non-nil error in case of I/O or decoding errors occuried,
|
|
// otherwise callback func accepts loaded [report.Report].
|
|
FetchReport(model.GameID, uint, func(report.Report, error))
|
|
}
|
|
|
|
type VersionInfo struct {
|
|
OS string `json:"os"` // Operating System name (unix, darwin, windows, etc.)
|
|
Version string `json:"version"` // Semver format: X.Y.Z
|
|
URL string `json:"url"` // URL for download artifacto for this version
|
|
}
|