app

package module
v0.0.0-...-bad9b23 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_CONFIG string = "/etc/susetelemetry/server.cfg"

Default server config path

Variables

This section is empty.

Functions

This section is empty.

Types

type APIConfig

type APIConfig struct {
	Host string `yaml:"host"`
	Port int    `yaml:"port"`
}

API server config

type App

type App struct {
	Config      *Config
	TelemetryDB DbConnection
	StagingDB   DbConnection
	Address     ServerAddress
	Handler     http.Handler
}

App is a struct tracking the resources associated with the application

func NewApp

func NewApp(cfg *Config, handler http.Handler) *App

func (*App) DeleteTelemetryReport

func (a *App) DeleteTelemetryReport(report *telemetrylib.TelemetryReport) (err error)

func (*App) Initialize

func (a *App) Initialize()

func (*App) ListenOn

func (a *App) ListenOn() string

func (*App) ProcessBundles

func (a *App) ProcessBundles(report *telemetrylib.TelemetryReport) (err error)

func (*App) RegisterClient

func (a *App) RegisterClient(ar *AppRequest)

RegisterClient is responsible for handling client registrations

func (*App) ReportTelemetry

func (a *App) ReportTelemetry(ar *AppRequest)

func (*App) Run

func (a *App) Run()

func (*App) StoreTelemetryData

func (a *App) StoreTelemetryData(dataItem *telemetrylib.TelemetryDataItem, bHeader *telemetrylib.TelemetryBundleHeader) (err error)

func (*App) StoreTelemetryReport

func (a *App) StoreTelemetryReport(reqBody []byte, key string) (err error)

type AppRequest

type AppRequest struct {
	W    http.ResponseWriter
	R    *http.Request
	Vars map[string]string
}

AppRequest is a struct tracking the resources associated with handling a request

func (*AppRequest) ContentType

func (ar *AppRequest) ContentType(contentType string)

func (*AppRequest) ContentTypeJSON

func (ar *AppRequest) ContentTypeJSON()

func (*AppRequest) ErrorResponse

func (ar *AppRequest) ErrorResponse(code int, errorMessage string)

func (*AppRequest) JsonResponse

func (ar *AppRequest) JsonResponse(code int, payload any)

func (*AppRequest) Status

func (ar *AppRequest) Status(statusCode int)

func (*AppRequest) StatusInternalServerError

func (ar *AppRequest) StatusInternalServerError()

func (*AppRequest) Write

func (ar *AppRequest) Write(data []byte) (code int, err error)

type ClientsRow

type ClientsRow struct {
	Id               int64  `json:"id"`
	ClientInstanceId string `json:"clientInstanceId"`
	RegistrationDate string `json:"registrationDate"`
	AuthToken        string `json:"authToken"`
}

func (*ClientsRow) Exists

func (c *ClientsRow) Exists(DB *sql.DB) bool

func (*ClientsRow) Insert

func (c *ClientsRow) Insert(DB *sql.DB) (err error)

func (*ClientsRow) String

func (c *ClientsRow) String() string

type Config

type Config struct {
	API APIConfig `yaml:"api"`
	//DataStores config.DBConfig `yaml:"datastores"`
	DataBases struct {
		Telemetry DBConfig `yaml:"telemetry"`
		Staging   DBConfig `yaml:"staging"`
	} `yaml:"dbs"`
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(cfgFile string) *Config

func (*Config) Load

func (cfg *Config) Load() error

func (*Config) Path

func (cfg *Config) Path() string

type DBConfig

type DBConfig struct {
	Driver string `yaml:"driver"`
	Params string `yaml:"params"`
}

func (*DBConfig) Valid

func (d *DBConfig) Valid() error

type DbConnection

type DbConnection struct {
	Conn       *sql.DB
	Driver     string
	DataSource string
}

DbConnection is a struct tracking a DB connection and associated DB settings

func (*DbConnection) Connect

func (d *DbConnection) Connect() (err error)

func (*DbConnection) EnsureTablesExist

func (d *DbConnection) EnsureTablesExist(tables map[string]string) (err error)

func (*DbConnection) Setup

func (d *DbConnection) Setup(dbcfg DBConfig)

func (DbConnection) String

func (d DbConnection) String() string

type PQLConfig

type PQLConfig struct {
	Host     string `yaml:"host"`
	Port     string `yaml:"port"`
	User     string `yaml:"user"`
	Password string `yaml:"password"`
	Name     string `yaml:"name"`
	SSLMode  string `yaml:"sslmode"`
	Cert     string `yaml:"cert"`
}

type ReportStagingTableRow

type ReportStagingTableRow struct {
	Key               string
	Data              interface{}
	Processed         bool
	ReceivedTimestamp string
}

func (*ReportStagingTableRow) Delete

func (r *ReportStagingTableRow) Delete(DB *sql.DB) (err error)

func (*ReportStagingTableRow) Exists

func (r *ReportStagingTableRow) Exists(DB *sql.DB) bool

func (*ReportStagingTableRow) Insert

func (r *ReportStagingTableRow) Insert(DB *sql.DB) (err error)

type ServerAddress

type ServerAddress struct {
	Hostname string
	Port     int
}

ServerAddress is a struct tracking the server address

func (*ServerAddress) Setup

func (s *ServerAddress) Setup(api APIConfig)

func (ServerAddress) String

func (s ServerAddress) String() string

type TagSetRow

type TagSetRow struct {
	Id     int64  `json:"id"`
	TagSet string `json:"tagSet"`
}

func (*TagSetRow) Exists

func (t *TagSetRow) Exists(DB *sql.DB) bool

func (*TagSetRow) Insert

func (t *TagSetRow) Insert(DB *sql.DB) (err error)

func (*TagSetRow) String

func (t *TagSetRow) String() string

type TelemetryDataRow

type TelemetryDataRow struct {
	Id            int64       `json:"id"`
	ClientId      int64       `json:"clientId"`
	CustomerId    string      `json:"customerId"`
	TelemetryId   string      `json:"telemetryId"`
	TelemetryType string      `json:"telemetryType"`
	Timestamp     string      `json:"timestamp"`
	TagSetId      int64       `json:"tagSetId"`
	Staged        bool        `json:"staged"`
	DataItem      interface{} `json:"dataItem"`
}

func (*TelemetryDataRow) Exists

func (t *TelemetryDataRow) Exists(DB *sql.DB) bool

func (*TelemetryDataRow) Insert

func (t *TelemetryDataRow) Insert(DB *sql.DB) (err error)

func (*TelemetryDataRow) String

func (t *TelemetryDataRow) String() string

Jump to

Keyboard shortcuts

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