userid

package
v1.92.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package userid exposes the persistent UUID identifying this cagent installation. The value is stored in `$configDir/user-uuid`, generated lazily on first use, and shared across cagent runs on the same machine.

It is consumed both by telemetry (as the `user_uuid` event property) and by the HTTP transport (as the `X-Cagent-Id` header on gateway-bound requests) so that the gateway can correlate calls made by the same cagent install without having to invent a new identifier.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get() string

Get returns the persistent UUID using the default resolver, which reads from paths.GetConfigDir.

Types

type Resolver added in v1.92.0

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

Resolver owns the directory it reads from and the in-memory cache of the resolved UUID. Each instance is fully independent, so tests can create one per testing.T.TempDir and run in parallel without sharing any global state.

func New added in v1.92.0

func New(dir string) *Resolver

New returns a Resolver that reads and writes the UUID file in dir.

func (*Resolver) Get added in v1.92.0

func (r *Resolver) Get() string

Get returns the persistent UUID identifying this cagent installation.

On the first call it tries to read the value from `<dir>/user-uuid`; if the file does not exist, is empty, contains an invalid UUID, or cannot be read, a fresh UUID is generated and persisted (best effort). The result is cached in memory for the lifetime of the resolver so subsequent calls do not touch the filesystem.

Jump to

Keyboard shortcuts

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