Documentation ¶
Overview ¶
Package id implements Service to provide simple ID generation using pseudo random strings.
Index ¶
Constants ¶
View Source
const ( // Hex128 creates a new hexa decimal encoded, pseudo random, 128 bit hash. Hex128 int = 16 // Hex512 creates a new hexa decimal encoded, pseudo random, 512 bit hash. Hex512 int = 64 // Hex1024 creates a new hexa decimal encoded, pseudo random, 1024 bit hash. Hex1024 int = 128 // Hex2048 creates a new hexa decimal encoded, pseudo random, 2048 bit hash. Hex2048 int = 256 // Hex4096 creates a new hexa decimal encoded, pseudo random, 4096 bit hash. Hex4096 int = 512 )
Variables ¶
This section is empty.
Functions ¶
func IsInvalidConfig ¶
IsInvalidConfig asserts invalidConfigError.
Types ¶
type Service ¶
type Service interface { // New tries to create a new object ID using the configured ID type. The // returned error might be caused by timeouts reached during the ID creation. New() (string, error) // WithType tries to create a new object ID using the given ID type. The // returned error might be caused by timeouts reached during the ID creation. WithType(idType int) (string, error) }
Service provides pseudo random hash generation used for ID assignment.
func NewService ¶
func NewService(config ServiceConfig) (Service, error)
NewService creates a new configured ID service.
type ServiceConfig ¶
type ServiceConfig struct { // RandomService represents a factory returning random numbers. RandomService random.Service // HashChars represents the characters used to create hashes. HashChars string // Length defines the ID bit size. Length int }
ServiceConfig represents the configuration used to create a new ID service.
func DefaultServiceConfig ¶
func DefaultServiceConfig() ServiceConfig
DefaultServiceConfig provides a default configuration to create a new ID service by best effort.
Click to show internal directories.
Click to hide internal directories.