app

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2025 License: Apache-2.0 Imports: 28 Imported by: 3

Documentation

Index

Constants

View Source
const (
	ANONYMOUS_CUSTOMER_ID = "ANONYMOUS"
)
View Source
const DEFAULT_AUTH_TIME_DURATION time.Duration = time.Hour * 24 * 7

use 1 week as default time duration

Variables

This section is empty.

Functions

func DisableTelemetryReportStaging added in v0.1.11

func DisableTelemetryReportStaging()

Disable telemetry report staging by default

func EnableTelemetryReportStaging added in v0.1.11

func EnableTelemetryReportStaging()

Enable telemetry report staging by default

func GetVersion added in v0.1.14

func GetVersion() string

func ReqLogger

func ReqLogger(r *http.Request) *slog.Logger

Types

type App

type App struct {
	// public
	Name          string
	Config        *config.Config
	TelemetryDB   *database.AppDb
	OperationalDB *database.AppDb
	Address       ServerAddress
	Handler       http.Handler
	LogManager    *logging.LogManager
	AuthManager   *AuthManager
	// contains filtered or unexported fields
}

App is a struct tracking the resources associated with the application

func NewApp

func NewApp(name string, cfg *config.Config, handler http.Handler, debugMode bool) *App

func (*App) AuthenticateClient

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

RegisterClient is responsible for handling client registrations

func (*App) GetCustomerRefId

func (a *App) GetCustomerRefId(customerId string) (customerRefId int64, err error)

func (*App) GetTagSetId

func (a *App) GetTagSetId(tagSet string) (tagSetId int64, err error)

func (*App) HealthCheck

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

func (*App) Initialize

func (a *App) Initialize() (err error)

func (*App) ListenAndServe

func (a *App) ListenAndServe() (err error)

func (*App) ListenOn

func (a *App) ListenOn() string

func (*App) LiveCheck added in v0.1.11

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

func (*App) ProcessStagedReport

func (a *App) ProcessStagedReport(reportRow *database.ReportStagingTableRow) (err error)

func (*App) ProcessStagedReports

func (a *App) ProcessStagedReports() error

func (*App) ProcessTelemetryReport added in v0.1.11

func (a *App) ProcessTelemetryReport(report *telemetrylib.TelemetryReport) 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) SetupLogging

func (a *App) SetupLogging() error

func (*App) Shutdown

func (a *App) Shutdown() (err error)

func (*App) StageTelemetryReport

func (a *App) StageTelemetryReport(reqBody []byte, rHeader *telemetrylib.TelemetryReportHeader) (stagingId int64, err error)

func (*App) StoreTelemetry

func (a *App) StoreTelemetry(
	dItm *telemetrylib.TelemetryDataItem,
	bHdr *telemetrylib.TelemetryBundleHeader,
) (err error)

func (*App) StoreTelemetryData

func (a *App) StoreTelemetryData(
	dItm *telemetrylib.TelemetryDataItem,
	bHdr *telemetrylib.TelemetryBundleHeader,
	tagSetId int64,
	customerRefId int64,
) (err error)

func (*App) Version added in v0.1.14

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

type AppRequest

type AppRequest struct {
	W     http.ResponseWriter
	R     *http.Request
	Vars  AppVars
	Log   *slog.Logger
	Quiet bool
}

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

func NewAppRequest

func NewAppRequest(w http.ResponseWriter, r *http.Request, v AppVars) *AppRequest

func QuietAppRequest

func QuietAppRequest(w http.ResponseWriter, r *http.Request, v AppVars) (ar *AppRequest)

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) GetAuthToken

func (ar *AppRequest) GetAuthToken() string

func (*AppRequest) GetAuthorization

func (ar *AppRequest) GetAuthorization() string

func (*AppRequest) GetHeader

func (ar *AppRequest) GetHeader(header string) (value string)

func (*AppRequest) GetRegistrationId

func (ar *AppRequest) GetRegistrationId() string

func (*AppRequest) JsonResponse

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

func (*AppRequest) SetHeader

func (ar *AppRequest) SetHeader(header, value string)

func (*AppRequest) SetWwwAuthReauth

func (ar *AppRequest) SetWwwAuthReauth()

func (*AppRequest) SetWwwAuthRegister

func (ar *AppRequest) SetWwwAuthRegister()

func (*AppRequest) SetWwwAuthScope

func (ar *AppRequest) SetWwwAuthScope(scope string)

func (*AppRequest) SetWwwAuthenticate

func (ar *AppRequest) SetWwwAuthenticate(challenge, realm, scope string)

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 AppVars

type AppVars map[string]string

AppVars is a map var name to value

type AuthManager

type AuthManager struct {
	// contains filtered or unexported fields
}

func NewAuthManager

func NewAuthManager(ac *config.AuthConfig) (am *AuthManager, err error)

func (*AuthManager) CreateToken

func (am *AuthManager) CreateToken() (tokenString string, err error)

func (*AuthManager) Issuer

func (am *AuthManager) Issuer() string

func (*AuthManager) SigningMethod

func (am *AuthManager) SigningMethod() jwt.SigningMethod

func (*AuthManager) Subject

func (am *AuthManager) Subject(sub any) string

func (*AuthManager) ValidMethods

func (am *AuthManager) ValidMethods() []string

func (*AuthManager) VerifyToken

func (am *AuthManager) VerifyToken(tokenString string) (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 config.APIConfig)

func (ServerAddress) String

func (s ServerAddress) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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