hostid

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: Apache-2.0 Imports: 8 Imported by: 5 modules, 8 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package hostid provides a configuration struct for resolving a host ID from YAML.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	// Resolver is the resolver for the host ID.
	Resolver Resolver `yaml:"resolver"`

	// Value is the config specified host ID if using config host ID resolver.
	Value *string `yaml:"value"`

	// EnvVarName is the environment specified host ID if using environment host ID resolver.
	EnvVarName *string `yaml:"envVarName"`

	// File is the file config.
	File *FileConfig `yaml:"file"`

	// Hostname is the hostname config.
	Hostname *HostnameConfig `yaml:"hostname"`
}

Configuration is the configuration for resolving a host ID.

func (Configuration) Resolve

func (c Configuration) Resolve() (string, error)

Resolve returns the resolved host ID given the configuration.

type FileConfig

type FileConfig struct {
	// Path of the file containing the host ID.
	Path string `yaml:"path"`

	// Timeout to wait for the file to be non-empty.
	Timeout *time.Duration `yaml:"timeout"`
}

FileConfig contains the info needed to construct a FileResolver.

type HostnameConfig added in v0.15.0

type HostnameConfig struct {
	// Format is a custom format to use, using go templates.
	// i.e. Using the M3DB operator if using no ID based on the disk
	// you can format it how the operator would expect:
	// '{"name":"{{.Hostname}}"}'
	Format string `yaml:"format"`
}

HostnameConfig contains the info needed to construct a HostnameConfig.

type IDResolver

type IDResolver interface {
	ID() (string, error)
}

IDResolver represents a method of resolving host identity.

type Resolver

type Resolver string

Resolver is a type of host ID resolver

const (
	// HostnameResolver resolves host using the hostname returned by OS
	HostnameResolver Resolver = "hostname"
	// ConfigResolver resolves host using a value provided in config
	ConfigResolver Resolver = "config"
	// EnvironmentResolver resolves host using an environment variable
	// of which the name is provided in config
	EnvironmentResolver Resolver = "environment"
	// FileResolver reads its identity from a non-empty file.
	FileResolver Resolver = "file"
)

Jump to

Keyboard shortcuts

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