idgen

package
v1.5.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// JobIDPrefix is the prefix of job ID.
	JobIDPrefix = "j-"

	// ExecutionIDPrefix is the prefix of execution ID.
	ExecutionIDPrefix = "e-"

	// EvaluationIDPrefix is the prefix of evaluation ID.
	EvaluationIDPrefix = "v-"

	// NodeIDPrefix is the prefix of node ID.
	NodeIDPrefix = "n-"
)
View Source
const ShortIDLength = 8
View Source
const ShortIDLengthWithPrefix = ShortIDLength + len(JobIDPrefix)

Variables

This section is empty.

Functions

func NewEvaluationID

func NewEvaluationID() string

NewEvaluationID generates a new evaluation ID.

func NewExecutionID

func NewExecutionID() string

NewExecutionID generates a new execution ID.

func NewJobID

func NewJobID() string

NewJobID generates a new job ID.

func ShortNodeID added in v1.2.2

func ShortNodeID(input string) string

ShortNodeID takes a string in the format of a libp2p peer ID or UUID, and returns a shortened version of the input, or the input as is if it doesn't match. Mainly used for logging and printing the ID in a more human-readable format.

func ShortUUID added in v1.2.2

func ShortUUID(input string) string

ShortUUID takes a string in the format of "prefix-UUID" or just "UUID" and returns the prefix along with the first segment of the UUID. For example: - For "e-78faf114-6a45-457e-825c-40fd2fad768f", it returns "e-78faf114". - For "j-78faf114-6a45-457e-825c-40fd2fad768f", it returns "j-78faf114". - For "78faf114-6a45-457e-825c-40fd2fad768f", it returns "78faf114".

Types

type AWSNodeNameProvider added in v1.2.2

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

AWSNodeNameProvider retrieves the node name from AWS instance metadata.

func NewAWSNodeNameProvider added in v1.2.2

func NewAWSNodeNameProvider() AWSNodeNameProvider

func (AWSNodeNameProvider) GenerateNodeName added in v1.2.2

func (p AWSNodeNameProvider) GenerateNodeName(ctx context.Context) (string, error)

type CachedNodeNameProvider added in v1.2.2

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

CachedNodeNameProvider caches the node name for subsequent calls.

func NewCachedNodeNameProvider added in v1.2.2

func NewCachedNodeNameProvider(provider NodeNameProvider) *CachedNodeNameProvider

func (*CachedNodeNameProvider) GenerateNodeName added in v1.2.2

func (c *CachedNodeNameProvider) GenerateNodeName(ctx context.Context) (string, error)

type GCPNodeNameProvider added in v1.2.2

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

GCPNodeNameProvider retrieves the node name from GCP instance metadata.

func NewGCPNodeNameProvider added in v1.2.2

func NewGCPNodeNameProvider() GCPNodeNameProvider

func (GCPNodeNameProvider) GenerateNodeName added in v1.2.2

func (p GCPNodeNameProvider) GenerateNodeName(ctx context.Context) (string, error)

type HTTPNodeNameProvider added in v1.2.2

type HTTPNodeNameProvider struct {
	URL    string
	Header map[string]string
}

HTTPNodeNameProvider retrieves the node name from a URL, used by AWS and GCP.

func (HTTPNodeNameProvider) GenerateNodeName added in v1.2.2

func (h HTTPNodeNameProvider) GenerateNodeName(ctx context.Context) (string, error)

type HostnameProvider added in v1.2.2

type HostnameProvider struct{}

HostnameProvider retrieves the node name from the host's hostname.

func (HostnameProvider) GenerateNodeName added in v1.2.2

func (HostnameProvider) GenerateNodeName(_ context.Context) (string, error)

type NodeNameProvider added in v1.2.2

type NodeNameProvider interface {
	GenerateNodeName(ctx context.Context) (string, error)
}

NodeNameProvider defines an interface for generating node names.

type NodeNameProviderFunc added in v1.2.2

type NodeNameProviderFunc func(ctx context.Context) (string, error)

NodeNameProviderFunc type is an adapter to allow the use of ordinary functions as NodeNameProvider.

func (NodeNameProviderFunc) GenerateNodeName added in v1.2.2

func (f NodeNameProviderFunc) GenerateNodeName(ctx context.Context) (string, error)

GenerateNodeName allows NodeNameProviderFunc to implement NodeNameProvider.

type PUUIDNodeNameProvider added in v1.2.2

type PUUIDNodeNameProvider struct{}

PUUIDNodeNameProvider generates a random UUID as the node name, with "n-" prefix.

func (PUUIDNodeNameProvider) GenerateNodeName added in v1.2.2

func (PUUIDNodeNameProvider) GenerateNodeName(ctx context.Context) (string, error)

type UUIDNodeNameProvider added in v1.2.2

type UUIDNodeNameProvider struct{}

UUIDNodeNameProvider generates a random UUID as the node name.

func (UUIDNodeNameProvider) GenerateNodeName added in v1.2.2

func (UUIDNodeNameProvider) GenerateNodeName(_ context.Context) (string, error)

Jump to

Keyboard shortcuts

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