machine

package
v0.0.0-...-767721b Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2015 License: GPL-2.0 Imports: 7 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFailedToIdentify = errors.New("Failed to establish a unique ID of the device/machine.")

Functions

This section is empty.

Types

type CachingIdentifier

type CachingIdentifier struct {
	Identifier Identifier
	Dir        string
	File       string
}

CachingIdentifier stores an id in a file, trying to load first prior to dispatching to a subsequent MachineIdentifier

func (CachingIdentifier) Identify

func (self CachingIdentifier) Identify() ([]byte, error)

Identify tries to load the id from the configured file. If no id is stored, yet, it dispatches to a subsequent identifier, storing its result.

type ChainingIdentifier

type ChainingIdentifier struct {
	Current Identifier
	Next    Identifier
}

ChainingIdentifier satisfies Identify requests relying on a current and a next Identifier. If the call to Current fails, the request is handed over to Next.

func (ChainingIdentifier) Identify

func (self ChainingIdentifier) Identify() ([]byte, error)

Identify establishes an identity by first invoking Current. If Current.Identify fails, it hands over to Next.

type FileIdentifier

type FileIdentifier struct {
	Path string // Path to the file containing the ID.
}

FileIdentifier reads an ID from a file.

func (FileIdentifier) Identify

func (self FileIdentifier) Identify() ([]byte, error)

Identify tries to read the machine/device ID from the file under Path.

type Identifier

type Identifier interface {
	// Identify returns a byte-slice containing the globally-unique
	// ID of the machine.
	Identify() ([]byte, error)
}

Identifier abstracts ID generation for a device/machine.

func DefaultIdentifier

func DefaultIdentifier() (Identifier, error)

DefaultIdentifier sets up the default machine identifier that is used for tagging uploads.

type MACAddressIdentifier

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

func NewMACAddressIdentifier

func NewMACAddressIdentifier() MACAddressIdentifier

func (MACAddressIdentifier) Identify

func (self MACAddressIdentifier) Identify() ([]byte, error)

type MockIdentifier

type MockIdentifier struct {
	mock.Mock
}

func (*MockIdentifier) Identify

func (self *MockIdentifier) Identify() ([]byte, error)

type SHA512Identifier

type SHA512Identifier struct {
	Identifier Identifier
}

SHA512Identifier computes the SHA512 hash of the result of a MachineIdentifier.Identify call.

func (SHA512Identifier) Identify

func (self SHA512Identifier) Identify() ([]byte, error)

Identify calls into the contained Identifier instance and hashes the result if the call to the inner MachineIdentifier succeeds.

Jump to

Keyboard shortcuts

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