upgraderesponder

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VersionTagLatest  = "latest"
	AppMinimalVersion = "v0.0.1"

	InfluxDBMeasurement              = "upgrade_request"
	InfluxDBMeasurementDownSampling  = "upgrade_request_down_sampling"
	InfluxDBMeasurementByAppVersion  = "by_app_version_down_sampling"
	InfluxDBMeasurementByCountryCode = "by_country_code_down_sampling"

	InfluxDBContinuousQueryDownSampling  = "cq_upgrade_request_down_sampling"
	InfluxDBContinuousQueryByAppVersion  = "cq_by_app_version_down_sampling"
	InfluxDBContinuousQueryByCountryCode = "cq_by_country_code_down_sampling"
)

Variables

View Source
var (
	InfluxDBPrecisionNanosecond   = "ns" // ns is good for counting nodes
	InfluxDBDatabase              = "upgrade_responder"
	InfluxDBContinuousQueryPeriod = "1h"

	InfluxDBTagAppVersion             = "app_version"
	InfluxDBTagKubernetesVersion      = "kubernetes_version"
	InfluxDBTagLocationCity           = "city"
	InfluxDBTagLocationCountry        = "country"
	InfluxDBTagLocationCountryISOCode = "country_isocode"

	HTTPHeaderXForwardedFor = "X-Forwarded-For"
	ValueFieldKey           = "value" // A dummy InfluxDB field used to count the number of points
	ValueFieldValue         = 1
)

Functions

func NewRouter

func NewRouter(s *Server) *mux.Router

func ParseTime

func ParseTime(t string) (time.Time, error)

Types

type CheckUpgradeRequest

type CheckUpgradeRequest struct {
	AppVersion string `json:"appVersion"`

	ExtraTagInfo   map[string]string      `json:"extraTagInfo"`
	ExtraFieldInfo map[string]interface{} `json:"extraFieldInfo"`

	// Deprecated: replaced by ExtraTagInfo
	ExtraInfo map[string]string `json:"extraInfo"`
}

type CheckUpgradeResponse

type CheckUpgradeResponse struct {
	Versions                 []Version `json:"versions"`
	RequestIntervalInMinutes int       `json:"requestIntervalInMinutes"`
}

type DBCache added in v0.2.0

type DBCache struct {
	sync.RWMutex
	Database     string
	Precision    string
	SyncInterval time.Duration
	CacheSize    int
	BatchPoints  influxcli.BatchPoints
	InfluxClient influxcli.Client
	// contains filtered or unexported fields
}

func NewDBCache added in v0.2.0

func NewDBCache(database, precision string, syncInterval time.Duration, cacheSize int, influxClient influxcli.Client) (*DBCache, error)

func (*DBCache) AddPoint added in v0.2.0

func (c *DBCache) AddPoint(p *influxcli.Point)

func (*DBCache) Run added in v0.2.0

func (c *DBCache) Run(stop <-chan struct{})

func (*DBCache) Sync added in v0.2.0

func (c *DBCache) Sync()

type Location

type Location struct {
	City    string `json:"city"`
	Country struct {
		Name    string
		ISOCode string
	} `json:"country"`
}

type RequestSchema added in v0.2.0

type RequestSchema struct {
	AppVersionSchema     Schema            `json:"appVersionSchema"`
	ExtraTagInfoSchema   map[string]Schema `json:"extraTagInfoSchema"`
	ExtraFieldInfoSchema map[string]Schema `json:"extraFieldInfoSchema"`
}

type ResponseConfig

type ResponseConfig struct {
	Versions []Version `json:"versions"`
}

type Schema added in v0.2.0

type Schema struct {
	DataType string `json:"dataType"`
	MaxLen   int    `json:"maxLen"`
}

func (*Schema) Validate added in v0.2.0

func (sc *Schema) Validate(value interface{}) (isValid bool)

type Server

type Server struct {
	VersionMap     map[string]*Version
	TagVersionsMap map[string][]*Version

	RequestSchema RequestSchema
	// contains filtered or unexported fields
}

func NewServer

func NewServer(done chan struct{}, applicationName, responseConfigFilePath, requestSchemaFilePath, influxURL, influxUser, influxPass, queryPeriod, geodb string, cacheSyncInterval, cacheSize int) (*Server, error)

func (*Server) CheckUpgrade

func (s *Server) CheckUpgrade(rw http.ResponseWriter, req *http.Request)

func (*Server) GenerateCheckUpgradeResponse

func (s *Server) GenerateCheckUpgradeResponse(request *CheckUpgradeRequest) (*CheckUpgradeResponse, error)

func (*Server) HealthCheck

func (s *Server) HealthCheck(rw http.ResponseWriter, req *http.Request)

func (*Server) ValidateExtraInfo added in v0.2.0

func (s *Server) ValidateExtraInfo(key string, value interface{}, extraInfoType string) bool

type Version

type Version struct {
	Name                 string            `json:"name"` // must be in semantic versioning
	ReleaseDate          string            `json:"releaseDate"`
	MinUpgradableVersion string            `json:"minUpgradableVersion"` // can be empty or semantic versioning
	Tags                 []string          `json:"tags"`
	ExtraInfo            map[string]string `json:"extraInfo"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL