clientinfo

package
v0.0.0-...-bd33f34 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package clientinfo collects information about the client and its environment into an immutable ClientInfo value.

Default returns a ClientInfo pre-populated with process-level defaults (SDK version, Go version, OS, and detected environment). ClientInfo.With derives a new value with additional key/value segments; it never mutates the original.

Databricks tooling (Terraform provider, CLI, partner integrations) should call SetProduct, SetPartner, or AddToDefault at startup to register global metadata before any client is created.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrOddKeyvals indicates an odd number of key/value arguments.
	ErrOddKeyvals = errors.New("odd number of key/value arguments")

	// ErrInvalidKey indicates a segment key with invalid characters.
	ErrInvalidKey = errors.New("invalid key")

	// ErrInvalidValue indicates a segment value with invalid characters.
	ErrInvalidValue = errors.New("invalid value")

	// ErrInvalidVersion indicates a version string that is not valid semver.
	ErrInvalidVersion = errors.New("invalid version")
)

Functions

func AddToDefault

func AddToDefault(key, value string) error

AddToDefault adds a global key/value segment that will be included in every Default call. Same key with different values is allowed (e.g., multiple partners). Exact key+value duplicates are silently ignored.

Must be called before any client is created. Not safe for concurrent use.

func SetPartner

func SetPartner(partner string) error

SetPartner adds a partner identifier globally. Partner attribution is a first-class concept used for support ticket routing.

Must be called before any client is created. Not safe for concurrent use.

func SetProduct

func SetProduct(name, version string) error

SetProduct sets the product name and version globally. The version must be a valid semver string.

Must be called before any client is created. Not safe for concurrent use.

Types

type ClientInfo

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

ClientInfo is an immutable, ordered list of key/value segments. Use Default to get the process-level defaults and ClientInfo.With to derive new values with additional segments.

func Default

func Default() ClientInfo

Default returns a ClientInfo populated with SDK metadata, runtime information, segments registered via AddToDefault, and automatically detected environment properties.

func (ClientInfo) String

func (ci ClientInfo) String() string

String returns a string representation of the client info suitable for inclusion in HTTP headers. Key/value pairs are formatted as "key/value" and joined by spaces in the order they were inserted.

func (ClientInfo) With

func (ci ClientInfo) With(keyvals ...string) (ClientInfo, error)

With returns a new ClientInfo with the given key/value pairs appended. The original is not modified. An odd number of arguments returns an error.

Keys and values must contain only alphanumeric characters plus the characters: undescore ('_'), dot ('.'), plus ('+'), or hyphen ('-').

Exact key+value duplicates are silently ignored. On error, the zero value is returned (all-or-nothing).

Jump to

Keyboard shortcuts

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