Documentation
¶
Index ¶
- Constants
- func ApplyCredentials(accounts []core.AccountConfig) []core.AccountConfig
- func DisabledAccountsFromConfig() map[string]bool
- func DisabledAccountsFromDashboard(dashboardCfg config.DashboardConfig) map[string]bool
- func EnsureSocketPathAvailable(socketPath string) error
- func FilterAccountsByDashboard(accounts []core.AccountConfig, dashboardCfg config.DashboardConfig) []core.AccountConfig
- func FlushInBatches(ctx context.Context, pipeline *telemetry.Pipeline, maxTotal int) (telemetry.FlushResult, []string)
- func HealthAPICompatible(health HealthResponse) bool
- func HealthCurrent(health HealthResponse) bool
- func HealthVersion(health HealthResponse) string
- func InstallService(socketPath string) error
- func IsReleaseSemver(value string) bool
- func LoadAccountsAndNorm() ([]core.AccountConfig, core.ModelNormalizationConfig, error)
- func ReadModelRequestKey(req ReadModelRequest) string
- func ReadModelTemplatesFromRequest(req ReadModelRequest, disabledAccounts map[string]bool) map[string]core.UsageSnapshot
- func ResolveAccounts(cfg *config.Config) []core.AccountConfig
- func ResolveSocketPath() string
- func ResolveSocketPathWithError() (string, error)
- func RunCommand(name string, args ...string) (string, error)
- func RunServer(cfg Config) error
- func ServiceStatus(socketPath string) error
- func SnapshotsHaveUsableData(snaps map[string]core.UsageSnapshot) bool
- func StartBroadcaster(ctx context.Context, rt *ViewRuntime, refreshInterval time.Duration, ...)
- func StartupDiagnostics(manager ServiceManager, socketPath string) string
- func TailFile(path string, maxLines int) string
- func TailTextLines(text string, maxLines int) string
- func UninstallService(socketPath string) error
- func WaitForHealth(ctx context.Context, client *Client, timeout time.Duration) error
- type Client
- func (c *Client) HealthInfo(ctx context.Context) (HealthResponse, error)
- func (c *Client) IngestHook(ctx context.Context, source string, accountID string, payload []byte) (HookResponse, error)
- func (c *Client) ReadModel(ctx context.Context, request ReadModelRequest) (map[string]core.UsageSnapshot, error)
- type Config
- type DaemonState
- type DaemonStatus
- type HealthResponse
- type HookResponse
- type ReadModelAccount
- type ReadModelRequest
- type ReadModelResponse
- type Service
- type ServiceManager
- func (m ServiceManager) Install() error
- func (m ServiceManager) InstallHint() string
- func (m ServiceManager) IsInstalled() bool
- func (m ServiceManager) IsSupported() bool
- func (m ServiceManager) Start() error
- func (m ServiceManager) StatusHint() string
- func (m ServiceManager) StderrLogPath() string
- func (m ServiceManager) StdoutLogPath() string
- func (m ServiceManager) Uninstall() error
- type SnapshotHandler
- type StateHandler
- type ViewRuntime
- func (r *ViewRuntime) CurrentClient() *Client
- func (r *ViewRuntime) EnsureClient(ctx context.Context) *Client
- func (r *ViewRuntime) ReadWithFallback(ctx context.Context) map[string]core.UsageSnapshot
- func (r *ViewRuntime) ResetEnsureThrottle()
- func (r *ViewRuntime) SetClient(client *Client)
- func (r *ViewRuntime) State() DaemonState
Constants ¶
View Source
const ( LaunchdDaemonLabel = "com.openusage.telemetryd" SystemdDaemonUnit = "openusage-telemetry.service" )
View Source
const APIVersion = "v1"
Variables ¶
This section is empty.
Functions ¶
func ApplyCredentials ¶
func ApplyCredentials(accounts []core.AccountConfig) []core.AccountConfig
func DisabledAccountsFromDashboard ¶
func DisabledAccountsFromDashboard(dashboardCfg config.DashboardConfig) map[string]bool
func FilterAccountsByDashboard ¶
func FilterAccountsByDashboard( accounts []core.AccountConfig, dashboardCfg config.DashboardConfig, ) []core.AccountConfig
func FlushInBatches ¶
func HealthAPICompatible ¶
func HealthAPICompatible(health HealthResponse) bool
func HealthCurrent ¶
func HealthCurrent(health HealthResponse) bool
func HealthVersion ¶
func HealthVersion(health HealthResponse) string
func InstallService ¶
func IsReleaseSemver ¶
func LoadAccountsAndNorm ¶
func LoadAccountsAndNorm() ([]core.AccountConfig, core.ModelNormalizationConfig, error)
func ReadModelRequestKey ¶
func ReadModelRequestKey(req ReadModelRequest) string
func ReadModelTemplatesFromRequest ¶
func ReadModelTemplatesFromRequest( req ReadModelRequest, disabledAccounts map[string]bool, ) map[string]core.UsageSnapshot
func ResolveAccounts ¶
func ResolveAccounts(cfg *config.Config) []core.AccountConfig
func ResolveSocketPath ¶
func ResolveSocketPath() string
func ServiceStatus ¶
func SnapshotsHaveUsableData ¶
func SnapshotsHaveUsableData(snaps map[string]core.UsageSnapshot) bool
func StartBroadcaster ¶
func StartBroadcaster( ctx context.Context, rt *ViewRuntime, refreshInterval time.Duration, handler SnapshotHandler, stateHandler StateHandler, )
func StartupDiagnostics ¶
func StartupDiagnostics(manager ServiceManager, socketPath string) string
func TailTextLines ¶
func UninstallService ¶
Types ¶
type Client ¶
type Client struct {
SocketPath string
// contains filtered or unexported fields
}
func EnsureRunning ¶
func (*Client) HealthInfo ¶
func (c *Client) HealthInfo(ctx context.Context) (HealthResponse, error)
func (*Client) IngestHook ¶
func (*Client) ReadModel ¶
func (c *Client) ReadModel( ctx context.Context, request ReadModelRequest, ) (map[string]core.UsageSnapshot, error)
type DaemonState ¶
type DaemonState struct {
Status DaemonStatus
Message string
InstallHint string
}
func ClassifyEnsureError ¶
func ClassifyEnsureError(err error) DaemonState
type DaemonStatus ¶
type DaemonStatus int
const ( DaemonStatusUnknown DaemonStatus = iota DaemonStatusConnecting // attempting to reach daemon DaemonStatusNotInstalled // service not installed DaemonStatusStarting // service installed, waiting for health DaemonStatusRunning // healthy and current DaemonStatusOutdated // healthy but wrong version DaemonStatusError // unrecoverable error )
type HealthResponse ¶
type HealthResponse struct {
Status string `json:"status"`
DaemonVersion string `json:"daemon_version,omitempty"`
APIVersion string `json:"api_version,omitempty"`
IntegrationVersion string `json:"integration_version,omitempty"`
}
func WaitForHealthInfo ¶
type HookResponse ¶
type ReadModelAccount ¶
type ReadModelRequest ¶
type ReadModelRequest struct {
Accounts []ReadModelAccount `json:"accounts"`
ProviderLinks map[string]string `json:"provider_links"`
}
func BuildReadModelRequest ¶
func BuildReadModelRequest( accounts []core.AccountConfig, providerLinks map[string]string, ) ReadModelRequest
func BuildReadModelRequestFromConfig ¶
func BuildReadModelRequestFromConfig() (ReadModelRequest, error)
type ReadModelResponse ¶
type ReadModelResponse struct {
Snapshots map[string]core.UsageSnapshot `json:"snapshots"`
}
type ServiceManager ¶
type ServiceManager struct {
Kind string
// contains filtered or unexported fields
}
func NewServiceManager ¶
func NewServiceManager(socketPath string) (ServiceManager, error)
func (ServiceManager) Install ¶
func (m ServiceManager) Install() error
func (ServiceManager) InstallHint ¶
func (m ServiceManager) InstallHint() string
func (ServiceManager) IsInstalled ¶
func (m ServiceManager) IsInstalled() bool
func (ServiceManager) IsSupported ¶
func (m ServiceManager) IsSupported() bool
func (ServiceManager) Start ¶
func (m ServiceManager) Start() error
func (ServiceManager) StatusHint ¶
func (m ServiceManager) StatusHint() string
func (ServiceManager) StderrLogPath ¶
func (m ServiceManager) StderrLogPath() string
func (ServiceManager) StdoutLogPath ¶
func (m ServiceManager) StdoutLogPath() string
func (ServiceManager) Uninstall ¶
func (m ServiceManager) Uninstall() error
type SnapshotHandler ¶
type SnapshotHandler func(map[string]core.UsageSnapshot)
type StateHandler ¶
type StateHandler func(DaemonState)
type ViewRuntime ¶
type ViewRuntime struct {
// contains filtered or unexported fields
}
func NewViewRuntime ¶
func NewViewRuntime( client *Client, socketPath string, verbose bool, ) *ViewRuntime
func (*ViewRuntime) CurrentClient ¶
func (r *ViewRuntime) CurrentClient() *Client
func (*ViewRuntime) EnsureClient ¶
func (r *ViewRuntime) EnsureClient(ctx context.Context) *Client
func (*ViewRuntime) ReadWithFallback ¶
func (r *ViewRuntime) ReadWithFallback(ctx context.Context) map[string]core.UsageSnapshot
func (*ViewRuntime) ResetEnsureThrottle ¶
func (r *ViewRuntime) ResetEnsureThrottle()
func (*ViewRuntime) SetClient ¶
func (r *ViewRuntime) SetClient(client *Client)
func (*ViewRuntime) State ¶
func (r *ViewRuntime) State() DaemonState
Click to show internal directories.
Click to hide internal directories.