Documentation
¶
Index ¶
- func Init(guidBitsSize int, estimatedGUIDs, scaleFactor int64)
- func SizeBits() int
- func SizeBytes() int
- type GUID
- func (g *GUID) AddOffset(offset string)
- func (g *GUID) BigInt() *big.Int
- func (g *GUID) Bytes() []byte
- func (g *GUID) Cmp(guid2 GUID) int
- func (g *GUID) Copy() *GUID
- func (g *GUID) Equals(guid2 GUID) bool
- func (g *GUID) GenerateInnerRandomGUID(topGUID GUID) (*GUID, error)
- func (g *GUID) GenerateInnerRandomGUIDScaled(topGUID GUID) (*GUID, error)
- func (g *GUID) Higher(guid2 GUID) bool
- func (g *GUID) Int64() int64
- func (g *GUID) Lower(guid2 GUID) bool
- func (g *GUID) PercentageOffset(offsetPercentage int, nextGuid GUID) string
- func (g *GUID) Short() string
- func (g *GUID) String() string
- type Range
- func (r *Range) CreatePartitions(partitionsPercentage []int) []*Range
- func (r *Range) GenerateRandom() (*GUID, error)
- func (r *Range) GenerateRandomSuperPeer() (*GUID, error)
- func (r *Range) HigherGUID() *GUID
- func (r *Range) Inside(guid GUID) bool
- func (r *Range) LowerGUID() *GUID
- func (r *Range) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type GUID ¶
type GUID struct {
// contains filtered or unexported fields
}
GUID represents a Global Unique Identifier (GUID) for a system's node
func MaximumGUID ¶
func MaximumGUID() *GUID
MaximumGUID creates the maximum available for the current defined number of bits.
func NewGUIDBytes ¶
NewGUIDBytes creates a new GUID based on an array of bytes representation of the identifier. Array of bytes is a representation of the number using the minimum number of bits.
func NewGUIDInteger ¶
NewGUIDInteger creates a new GUID based on an integer64 representation of the identifier.
func NewGUIDRandom ¶
func NewGUIDRandom() *GUID
NewGUIDRandom creates a random GUID in the range [0,MaxGUID).
func NewGUIDString ¶
NewGUIDString creates a new GUID based on a string representation (in base 10) of the identifier.
func (*GUID) Bytes ¶
Bytes returns an array of bytes (with size of guidSizeBits) with the value of the GUID.
func (*GUID) Cmp ¶
Cmp used to check what if the guid is higher, lower or equal than the given guid.
func (*GUID) GenerateInnerRandomGUID ¶
GenerateInnerRandomGUID generates a random GUID that belongs to the interval [this, topGUID).
func (*GUID) GenerateInnerRandomGUIDScaled ¶
GenerateInnerRandomGUIDScaled generates a random GUID that belongs to the interval [this, topGUID). But it returns one of a specific set of GUIDs from the interval. This set is small than the total GUIDs of the interval.
func (*GUID) Higher ¶
Higher returns true if guid is higher than the given guid and false otherwise.
func (*GUID) PercentageOffset ¶
PercentageOffset returns the number of ids (as a string with an integer in base 10) using % offset to higher GUID.
type Range ¶
type Range struct {
// contains filtered or unexported fields
}
Range represents a range of GUIDs (Global Unique Identifiers), i.e. [lowerGUID, higherGUID).
func NewGUIDRange ¶
NewGUIDRange creates a new GUID range given a lower GUID and higher GUID.
func (*Range) CreatePartitions ¶
CreatePartitions returns partitions, set of ranges, of the receiver range.
func (*Range) GenerateRandomSuperPeer ¶
GenerateRandomSuperPeer generate random GUID inside the range.
func (*Range) HigherGUID ¶
HigherGUID get the higher GUID of the range.