hostname

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeNotification

type ChangeNotification struct {
	What ChangeType
}

ChangeNotification is the struct being sent through the notification channel

type ChangeNotifier

type ChangeNotifier interface {
	AddObserver(name string, ch chan<- ChangeNotification)
	RemoveObserver(name string)
}

ChangeNotifier allows observer to register a channel to be notified of when the hostname is updated

type ChangeType

type ChangeType int

ChangeType represents the type of hostname change

const (
	// Short is the short hostname
	Short ChangeType = iota
	// Full is the FDQN hostname
	Full
	// ShortAndFull both were changed
	ShortAndFull
)

type Resolver

type Resolver interface {
	// Query returns the full and the short hostname, or error if the process has not been completed
	Query() (full, short string, err error)
	Long() string
}

Resolver provides full and short name resolving functionalities

type ResolverChangeNotifier

type ResolverChangeNotifier interface {
	Resolver
	ChangeNotifier
}

ResolverChangeNotifier is a sum of both Resolver and ChangeNotifier interfaces

func CreateResolver

func CreateResolver(overrideFull, overrideShort string, dnsResolution bool) ResolverChangeNotifier

CreateResolver creates a HostnameResolver. If overrideFull or overrideShort are not empty strings, the hostname won't resolve automatically but will use the passed values. If dnsResolution is true, returns a HostnameResolver that attempts to resolve the Fully Qualified Domain Name as the full hostname. If dnsResolution is false, returns a HostnameResolver resolves internally the full hostname (asking to the OS for it). If the full hostname resolution process fails (e.g. due to a temporary DNS failure), it returns the previous successful resolution (or the short hostname if it has never worked previously).

Jump to

Keyboard shortcuts

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